nginx 配置实例

来源:互联网 发布:面码仁太 知乎 编辑:程序博客网 时间:2024/06/16 02:45

支持部分页面SSL,整合apache的autoindex,支持fastcgi

[root@localhost ~]# cat /etc/nginx/nginx.conf user  nginx;worker_processes  1;error_log  /var/log/nginx/error.log warn;pid        /var/run/nginx.pid;events {    worker_connections  1024;}http {    include       /etc/nginx/mime.types;    default_type  application/octet-stream;    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                      '$status $body_bytes_sent "$http_referer" '                      '"$http_user_agent" "$http_x_forwarded_for"';    log_format  MySSL '$remote_addr - $remote_user [$time_local] "$request" '                      '$status $body_bytes_sent "$http_referer" '                      '"$http_user_agent" "$http_x_forwarded_for" '                      '"$ssl_cipher" "$ssl_protocol"';    access_log  /var/log/nginx/access.log  main;    sendfile        on;    tcp_nopush     on;    keepalive_timeout  65;    #gzip  on;    server_names_hash_bucket_size 128;    client_header_buffer_size 32k;    large_client_header_buffers 4 32k;    client_body_buffer_size 128k;    proxy_connect_timeout 600;    proxy_read_timeout 600;    proxy_send_timeout 600;    proxy_buffer_size 16k;    proxy_buffers 4 32k;    proxy_busy_buffers_size 64k;    proxy_temp_file_write_size 64k;    proxy_redirect off;    proxy_set_header Host $host;    proxy_set_header X-Real-IP $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    fastcgi_connect_timeout 300;    fastcgi_read_timeout 300;    fastcgi_send_timeout 300;    fastcgi_buffer_size 64k;    fastcgi_buffers 4 64k;    fastcgi_busy_buffers_size 128k;    fastcgi_temp_file_write_size 128k;    server {        listen       80;        listen       443 ssl;        server_name  localhost;         ssl_certificate        server.crt;        ssl_certificate_key      server.key;        ssl_session_cache       shared:SSL:10m;        ssl_session_timeout      10m;        keepalive_timeout       70;        #charset koi8-r;        access_log  /var/log/nginx/access.log  MySSL;        root   /var/www/html;        index  index.html index.htm;        #error_page  404              /404.html;        error_page   500 502 503 504  /50x.html;        location / {            if ( $https = on ) {                return 301 http://$host$request_uri;            }        }        location /certsrv {            if ( $https != on ) {                return 301 https://$host$request_uri;            }            autoindex on;            autoindex_localtime on;        }        location /download {            if ( $https = on ) {                return 301 http://$host$request_uri;            }            proxy_pass http://localhost:8080;            proxy_redirect http://localhost:8080/download http://$host$request_uri;        }        location ^~ /icons {            if ( $https = on ) {                return 301 http://$host$request_uri;            }            proxy_pass http://localhost:8080;            proxy_redirect http://localhost:8080/icons http://$host$request_uri;            location ~ \.(gif/png)$ {                valid_referers none blocked server_names                               www.wjc.com wjc.com *.wjc.com;                if ( $invalid_referer ) { return 403; }            }        }        location ~ \.(php|php5)$ {            if ( $https = on ) {                return 301 http://$host$request_uri;            }            if ( !-e $request_filename ) { return 404; }            fastcgi_pass unix:/dev/shm/php-fpm.socket;            fastcgi_param SCRIPT_FILENAME $request_filename;            include fastcgi_params;        }    }}[root@localhost ~]# 

0 0
原创粉丝点击