nginx多域名 多首页配置

发布时间 2023-11-07 09:30:16作者: zzzzxb
#user  nobody;
worker_processes  auto;
worker_cpu_affinity auto;
 
error_log  /midware/nginx/logs/error.log info;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
 
pid        logs/nginx.pid;
 
 
events {
    use epoll;
    worker_connections  65535;
    multi_accept off;
    accept_mutex off;
}
 
 
http {
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    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  /midware/nginx/logs/access.log  main;
 
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options SAMEORIGIN;
 
    sendfile        on;
    sendfile_max_chunk 512k;
    tcp_nopush     on;
    tcp_nodelay on;
    #keepalive_timeout  0;
    keepalive_timeout  15;
    client_body_timeout 60;
    client_header_timeout 60;
    send_timeout 60;
    #gzip  on;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
    gzip_vary on;
    gzip_proxied   expired no-cache no-store private auth;
    gzip_disable   "MSIE [1-6]\.";
 
   proxy_connect_timeout 300s;
        proxy_send_timeout   900;
        proxy_read_timeout   900;
        proxy_buffer_size    32k;
        proxy_buffers     4 32k;
        proxy_busy_buffers_size 64k;
        proxy_redirect     off;
        proxy_hide_header  Vary;
        proxy_set_header   Accept-Encoding '';
        proxy_set_header   Host   $http_host;
        proxy_set_header   Referer $http_referer;
        proxy_set_header   Cookie $http_cookie;
        # proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
 
    #limit_conn_zone $binary_remote_addr zone=perip:10m;
    ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
    server_tokens off;
    access_log off;
 
upstream ***backend {
ip_hash;
# 按服务IP 端口修改
server 10.52.21.163:8080 max_fails=3 fail_timeout=30s;
server 10.52.21.164:8080 max_fails=3 fail_timeout=30s;
}
 
upstream searchbackend {
ip_hash;
# 按服务IP 端口修改
server 10.52.21.161:8080 max_fails=3 fail_timeout=30s;
server 10.52.21.162:8080 max_fails=3 fail_timeout=30s;
}
 
upstream static_backend {
server localhost:80;
}
 
#主
    server {
       listen       80;
       listen       [::]:80 ipv6only=on;
       server_name  www.***.com.cn;
       charset utf-8;
root /midware/web;
index ***/index.html index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
#location / {
#expires 5m; 
#index ***/index.html index.html;
#}
 
location /ps***** {
#root /midware/web;
#index ps*****/index.shtml;
}
 
location / {
        #       expires 5m; 
         index ***/index.html index.html;
         }                             
 
       #access_log  logs/host.access.log  main;
 
       #location / {
        #    #root   html;
#    root /midware/web;
        #    #index  index.html index.htm;
#}
 
        #error_page  404              /404.html;
 
location /eportal {proxy_pass http://***backend/eportal;}
location /eportalapp {proxy_pass http://***backend/eportalapp;}
location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
location /eportalsite {proxy_pass http://***backend/eportalsite;}
location /eportalapply {proxy_pass http://***backend/eportalapply;}
location /search {proxy_pass http://searchbackend/search;}
location = /search/admin/toLogin.htm {
try_files  $uri /***/index.html =404;  
}
        error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
    }
 
 
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.df*****.com;
charset utf-8;
root /midware/web;
index df*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
#location ~^/(?!df*****|uiFramework|***/imageDir|eportal|eportalapp|eportalmsg|eportalsite|eportalapply|sitemap.*\.xml|robots.txt|/404.html){
#        return 301 http://www.***.com.cn$request_uri;
#}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
 
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.jd*****.com;
charset utf-8;
root /midware/web;
index jd*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.hc*****.com;
charset utf-8;
root /midware/web;
index hc*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.sl*****.com;
charset utf-8;
root /midware/web;
index sl*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.shulan*****.com;
charset utf-8;
root /midware/web;
index shulan*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.jh*****.com;
charset utf-8;
root /midware/web;
index jh*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.ccsy*****.com;
charset utf-8;
root /midware/web;
index ccsy*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.yq*****.com;
charset utf-8;
root /midware/web;
index yq*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
#副
server {
        listen       80;
listen       [::]:80;
        server_name  www.cx*****.com;
charset utf-8;
root /midware/web;
index cx*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
 
client_max_body_size 10M;
location / {
expires 5m; 
}
 
        location /eportal {proxy_pass http://***backend/eportal;}
        location /eportalapp {proxy_pass http://***backend/eportalapp;}
        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}
        location /eportalsite {proxy_pass http://***backend/eportalsite;}
        location /eportalapply {proxy_pass http://***backend/eportalapply;}
 
 
       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;
        location = /404.html {
            root   html;
        }
 
        }
 
}
#user  nobody;worker_processes  auto;worker_cpu_affinity auto;
error_log  /midware/nginx/logs/error.log info;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;
pid        logs/nginx.pid;

events {    use epoll;    worker_connections  65535;    multi_accept off;    accept_mutex off;}

http {    include       mime.types;    default_type  application/octet-stream;    server_names_hash_bucket_size 128;    client_header_buffer_size 32k;    large_client_header_buffers 4 32k;    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  /midware/nginx/logs/access.log  main;
    add_header X-Content-Type-Options nosniff;    add_header X-Frame-Options SAMEORIGIN;
    sendfile        on;    sendfile_max_chunk 512k;    tcp_nopush     on;    tcp_nodelay on;    #keepalive_timeout  0;    keepalive_timeout  15;    client_body_timeout 60;    client_header_timeout 60;    send_timeout 60;    #gzip  on;    gzip on;    gzip_min_length  1k;    gzip_buffers     4 16k;    gzip_http_version 1.1;    gzip_comp_level 2;    gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;    gzip_vary on;    gzip_proxied   expired no-cache no-store private auth;    gzip_disable   "MSIE [1-6]\.";
   proxy_connect_timeout 300s;        proxy_send_timeout   900;        proxy_read_timeout   900;        proxy_buffer_size    32k;        proxy_buffers     4 32k;        proxy_busy_buffers_size 64k;        proxy_redirect     off;        proxy_hide_header  Vary;        proxy_set_header   Accept-Encoding '';        proxy_set_header   Host   $http_host;        proxy_set_header   Referer $http_referer;        proxy_set_header   Cookie $http_cookie;        # proxy_set_header   X-Real-IP  $remote_addr;        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header   X-Forwarded-Proto $scheme;
    #limit_conn_zone $binary_remote_addr zone=perip:10m;    ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.    server_tokens off;    access_log off;
upstream ***backend {ip_hash;# 按服务IP 端口修改server 10.52.21.163:8080 max_fails=3 fail_timeout=30s;server 10.52.21.164:8080 max_fails=3 fail_timeout=30s;}
upstream searchbackend {ip_hash;# 按服务IP 端口修改server 10.52.21.161:8080 max_fails=3 fail_timeout=30s;server 10.52.21.162:8080 max_fails=3 fail_timeout=30s;}upstream static_backend {server localhost:80;}
#主    server {       listen       80;       listen       [::]:80 ipv6only=on;       server_name  www.***.com.cn;       charset utf-8;root /midware/web;index ***/index.html index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;#location / {#expires 5m; #index ***/index.html index.html;#}
location /ps***** {#root /midware/web;#index ps*****/index.shtml;}
location / {        #       expires 5m;          index ***/index.html index.html;         }                             
       #access_log  logs/host.access.log  main;
       #location / {        #    #root   html;#    root /midware/web;        #    #index  index.html index.htm;#}
        #error_page  404              /404.html;
location /eportal {proxy_pass http://***backend/eportal;}location /eportalapp {proxy_pass http://***backend/eportalapp;}location /eportalmsg {proxy_pass http://***backend/eportalmsg;}location /eportalsite {proxy_pass http://***backend/eportalsite;}location /eportalapply {proxy_pass http://***backend/eportalapply;}location /search {proxy_pass http://searchbackend/search;}location = /search/admin/toLogin.htm { try_files  $uri /***/index.html =404;  }        error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }    }

#副server {        listen       80;listen       [::]:80;        server_name  www.df*****.com;charset utf-8;root /midware/web;index df*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
#location ~^/(?!df*****|uiFramework|***/imageDir|eportal|eportalapp|eportalmsg|eportalsite|eportalapply|sitemap.*\.xml|robots.txt|/404.html){#        return 301 http://www.***.com.cn$request_uri;#}
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }
#副server {        listen       80;listen       [::]:80;        server_name  www.jd*****.com;charset utf-8;root /midware/web;index jd*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.hc*****.com;charset utf-8;root /midware/web;index hc*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.sl*****.com;charset utf-8;root /midware/web;index sl*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.shulan*****.com;charset utf-8;root /midware/web;index shulan*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.jh*****.com;charset utf-8;root /midware/web;index jh*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.ccsy*****.com;charset utf-8;root /midware/web;index ccsy*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.yq*****.com;charset utf-8;root /midware/web;index yq*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }#副server {        listen       80;listen       [::]:80;        server_name  www.cx*****.com;charset utf-8;root /midware/web;index cx*****/index/index.shtml index/index.html index/index.shtml index.html index.shtml;ssi on;ssi_silent_errors on;ssi_types text/shtml;client_max_body_size 10M;location / {expires 5m; }
        location /eportal {proxy_pass http://***backend/eportal;}        location /eportalapp {proxy_pass http://***backend/eportalapp;}        location /eportalmsg {proxy_pass http://***backend/eportalmsg;}        location /eportalsite {proxy_pass http://***backend/eportalsite;}        location /eportalapply {proxy_pass http://***backend/eportalapply;}

       error_page   400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506  /404.html;        location = /404.html {            root   html;        }
        }
}