nginx最全配置


user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

upstream www {
server 127.0.0.1:8080;
}
upstream manager {
server 127.0.0.1:10001;
}
upstream git {
server 127.0.0.1:3000;
}
upstream servicemanager {
server 127.0.0.1:18760;
}
upstream api {
server 127.0.0.1:18770;
}


    server {
        listen       80;
        server_name  www.nursezz.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass http://www;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
         

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
    }
        
    server {
        listen       80;
        server_name  manager.nursezz.com;
        rewrite ^(.*)$ https://manager.nursezz.com;
    }
    
     server {
        listen 443;
        server_name manager.nursezz.com;      
        ssl on;
        ssl_certificate    /usr/local/nginx/crt/2446407_manager.nursezz.com.pem;
        ssl_certificate_key    /usr/local/nginx/crt/2446407_manager.nursezz.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        root /data0/management-sys/statichtml/;
        index index.html;
        location / {
         index index.html index.htm;
        }
        
        error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
     
     
     server {
        listen       80;
        server_name  api.nursezz.com;
        rewrite ^(.*)$ https://api.nursezz.com;
    }
    
    
    server {
        listen 443;
        server_name api.nursezz.com;      
        ssl on;
        ssl_certificate    /usr/local/nginx/crt/2446419_api.nursezz.com.pem;
        ssl_certificate_key    /usr/local/nginx/crt/2446419_api.nursezz.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
         
        location / {
            proxy_pass http://api;
                        proxy_set_header Host $http_host;
                        proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        } 

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
     
    server {
        listen       80;
        server_name  git.nursezz.com;
 
    location / {
            proxy_pass http://git;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        } 
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
    }

server {
        listen       80;
        server_name  servicemanager.nursezz.com;

        location / {
            proxy_pass http://servicemanager;
                        proxy_set_header Host $http_host;
                        proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        } 

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

    server {
        listen       80;
        server_name  servant.nursezz.com;
                rewrite ^(.*)$ https://servant.nursezz.com;
    }
    
    server {
        listen 443;
        server_name servant.nursezz.com;
        client_max_body_size 8M;
        client_body_buffer_size 128k;
                ssl on;
        ssl_certificate /usr/local/nginx/crt/2846147_servant.nursezz.com.pem;
        ssl_certificate_key     /usr/local/nginx/crt/2846147_servant.nursezz.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        
        root /data0/nurse-sys/statichtml/;
        index index.html;
     
         
        location /weixinservice {
            proxy_pass http://127.0.0.1:18091/weixinservice;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        
        location /adminservice {
            proxy_pass http://127.0.0.1:18090/adminservice;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        
    location /file {
             alias  /data0/file/;
         index index.html;

        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章