nginx配置多個域名
阿新 • • 發佈:2020-12-16
server { listen 80; server_name www.aa.com aa.com bb.aa.com; #rewrite ^/(.*) https://$server_name$request_uri? permanent; #http重定向到https #rewrite ^/(.*) https://$server_name$1 permanent; #跳轉到Https #charset koi8-r; charset utf-8; if ($host = 'bb.aa.com') { rewrite ^/(.*) https://bb.aa.com/$1 permanent; } if ($host = 'aa.com') { rewrite ^/(.*) https://www.aa.com/$1 permanent; } return 301 https://$host$request_uri; } server { listen 443 ssl; server_name www.aa.com aa.com; #ssl on; ssl_certificate ./cert/20201111/4750650_www.aa.com.pem; ssl_certificate_key ./cert/20201111/4750650_www.aa.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://ip:埠號1; proxy_read_timeout 3000s; root html; index index.html; } } server { listen 443 ssl; server_name bb.aa.com; #ssl on; ssl_certificate ./cert/leadbot/20201117/_bb.aa.com.pem; ssl_certificate_key ./cert/leadbot/20201117/_bb.aa.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://ip:埠號2; proxy_read_timeout 3000s; } }