`

nginx配置模板

阅读更多
[root@localhost nginx]# cd conf/
[root@localhost conf]# ll
总用量 36
drwxr-xr-x. 2 richmail richmail 4096 2月   4 19:31 conf.d
-rwxr-xr-x. 1 richmail richmail 2837 2月   3 23:25 koi-utf
-rwxr-xr-x. 1 richmail richmail 2223 2月   3 23:25 koi-win
-rwxr-xr-x. 1 richmail richmail 3463 2月   3 23:25 mime.types
-rwxr-xr-x. 1 richmail richmail 2710 2月   3 17:40 nginx.conf
-rwxr-xr-x. 1 richmail richmail 1675 2月   3 23:25 privkey.pem
-rwxr-xr-x. 1 richmail richmail 4412 2月   3 23:25 server.pem
-rwxr-xr-x. 1 richmail richmail 3610 2月   3 23:25 win-utf
[root@localhost conf]# less nginx.conf 
user richmail richmail;
#worker_processes  4;
#worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 65535;
pid        /home/richmail/nginx/logs/nginx.pid;

events {
    use epoll;
    worker_connections 256; 
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    server_tokens off;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  30;
    tcp_nodelay on;
    log_format acc  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $upstream_response_time $body_bytes_sent "$http_referer" "$sent_http_location"'
                      '"$http_user_agent" "$http_x_forwarded_for"';
    gzip on;
    gzip_comp_level 2;
    gzip_http_version   1.1;
    gzip_types      text/plain application/x-javascript text/css application/xml text/javascript;
    gzip_proxied        any;
    gzip_vary   on;

    proxy_cache_path /home/richmail/nginx/cache levels=1:2 keys_zone=tmp_cache:1024m inactive=20m max_size=1024m;
    #proxy_set_header X-Forwarded-Proto https;
    add_header X-Frame-Options SAMEORIGIN;
    #add_header Cache-Control no-store; 

    server {
        listen       80;
        server_name _;
        access_log  /home/richmail/logs/xx.nginx.log acc;
        error_log  /home/richmail/logs/xx.nginx.err  info;
        root /home/richmail/nginx/html;
        proxy_intercept_errors on;
        error_page   500 /error.html;
        error_page   404 /404.html;
user richmail richmail;
#worker_processes  4;
#worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 65535;
pid        /home/richmail/nginx/logs/nginx.pid;

events {
    use epoll;
    worker_connections 256; 
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    server_tokens off;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  30;
    tcp_nodelay on;
    log_format acc  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $upstream_response_time $body_bytes_sent "$http_referer" "$sent_http_location"'
                      '"$http_user_agent" "$http_x_forwarded_for"';
    gzip on;
    gzip_comp_level 2;
    gzip_http_version   1.1;
    gzip_types      text/plain application/x-javascript text/css application/xml text/javascript;
    gzip_proxied        any;
    gzip_vary   on;

    proxy_cache_path /home/richmail/nginx/cache levels=1:2 keys_zone=tmp_cache:1024m inactive=20m max_size=1024m;
    #proxy_set_header X-Forwarded-Proto https;
    add_header X-Frame-Options SAMEORIGIN;
    #add_header Cache-Control no-store; 

    server {
        listen       80;
        server_name _;
        access_log  /home/richmail/logs/xx.nginx.log acc;
        error_log  /home/richmail/logs/xx.nginx.err  info;
        root /home/richmail/nginx/html;
        proxy_intercept_errors on;
        error_page   500 /error.html;
        error_page   404 /404.html;
        error_page   404 /404.html;
        }

    server {
        listen       80;
        server_name webnote.com 127.0.0.1 192.168.34.92;
        access_log  /home/richmail/logs/mail.nginx.log acc;
        error_log  /home/richmail/logs/mail.nginx.err  info;
        proxy_intercept_errors on;
        error_page   500 502 503 504 /error.html;
        error_page   404 /404.html;
        error_page   403 =404 /forbidden.gif;
        if ($request_method !~* GET|HEAD|POST) {
                return 400;
        }
        include conf.d/note.conf;
    }
    server {
        listen       443;
        server_name webnote.com 127.0.0.1 192.168.34.92;
        access_log  /home/richmail/logs/mailssl.nginx.log acc;
        error_log  /home/richmail/logs/mailssl.nginx.err  info;
        proxy_intercept_errors on;
        error_page   500 502 503 504 /error.html;
        error_page   404 /404.html;
        error_page   403 =404 /forbidden.gif;
        if ($request_method !~* GET|HEAD|POST) {
                return 400;
        }
        add_header Cache-Control no-store;
        add_header Pragma: no-cache;
        ssl on;
        ssl_certificate server.pem;
        ssl_certificate_key privkey.pem;
        include conf.d/note.conf;
        }
}
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics