欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

自己亲自做的 一个ok的nginx.conf 图像通过nginx 不经过apache http 了 私有文件图像无法显示 但是 pdf 显示却是正常的 有大用 有大大用

着重看下面红色的 

server {

        listen       80;

        root /www/web/bbbb_aaa-ict_com/public_html;

        server_name bbbb.aaa-ict.com;

        index  index.html index.php index.htm;

        error_page  400 /errpage/400.html;

        error_page  403 /errpage/403.html;

        error_page  404 /errpage/404.html;

        error_page  503 /errpage/503.html;

        location ~ \.php$ {

                proxy_pass http://127.0.0.1:88;

                include naproxy.conf;

        }

        location ~ system/files/.*\.(gif|jpg|jpeg|png|bmp|swf)$ {

                 rewrite ^/(.*)$ /index.php?q=$1 last;

                 break;

        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {

                expires      1d;

        }

        location ~ .*\.(js|css|htm)?$ {

                expires      12h;

        }

        location ~ /\.ht {

                deny  all;

        }

        location / {

                try_files $uri @apache;

        }

  location @apache {

                 internal;

                 proxy_pass http://127.0.0.1:88;

                 include naproxy.conf;

        }

}




下面的可以不看了 


server {

        listen       80;

        root /www/web/jsfaq_aaaaaa-ict_com/public_html;

        server_name jsfaq.aaaaaa-ict.com;

        index  index.html index.php index.htm;

        error_page  400 /errpage/400.html;

        error_page  403 /errpage/403.html;

        error_page  404 /errpage/404.html;

        error_page  503 /errpage/503.html;

        rewrite  ^/sites/default/files/styles/thumbnail/public/pictures/(.*)$ /sites/default/files/pictures/$1 last;  //伪静态 重定向 有大用           这里rewrite放在server 里面,如果rewrite放在location,里面,就用break来替代last了

        rewrite  ^/sites/default/files/styles/thumbnail/public/pictures/(.*)$ /sites/default/files/pictures/$1 permanent;  //重定向 有大用

        location ~ \.php$ {

                proxy_pass http://127.0.0.1:88;

                include naproxy.conf;

        }

        location  /pdf/ {

                return 404;

        }

        location ~*  /pdf/.*\.(gif|jpg|jpeg|png)$ {

                valid_referers  blocked *.aaaaaa-ict.com;

                if ($invalid_referer){

                    return 404;

                }

        }

        location  /doc/ {

                return 404;

        }

        location ~*  /doc/.*\.(gif|jpg|jpeg|png)$ {

                valid_referers  blocked *.aaaaaa-ict.com;

                if ($invalid_referer){

                    return 404;

                }

        }

        location ~*  /sites/default/files/private/.*\.(gif|jpg|jpeg|png|pdf|pptx|xls|xlsx|csv|html|txt|htm)$ {

                valid_referers  blocked *.aaaaaa-ict.com;

                if ($invalid_referer){

                    return 404;

                }

        }

     #location  /sites/default/files/style/thumbnail/public/pictures/ {

        #       rewrite  /sites/default/files/style/thumbnail/public/pictures/(.*)$  /sites/default/files/pictures/$1 break;

        #}

        location ~ system.*\.(gif|jpg|jpeg|png|bmp|swf)$ {

                proxy_pass http://127.0.0.1:88;

                include naproxy.conf;

        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {

                expires      1d;

        }

        location ~ .*\.(js|css|htm)?$ {

                expires      12h;

        }

        location ~ /\.ht {

                deny  all;

        }

        location / {

                try_files $uri @apache;

        }

        location @apache {

                 internal;

                 proxy_pass http://127.0.0.1:88;

                 include naproxy.conf;

        }

}


普通分类: