网站设置二级域名的nginx配置
nginx的配置如下
upstream myblog { server 127.0.0.1:8000; } upstream myreport{ server 127.0.0.1:3000; } server { listen 443 ssl; server_name www.blog.xiaozhumaopao.com; ssl_certificate cert/3063067_xiaozhumaopao.com.pem; ssl_certificate_key cert/3063067_xiaozhumaopao.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_set_header X-Forwarded-Host $server_name; proxy_pass http://myblog; proxy_redirect off; } location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|pdf|txt|html){ root /home/zyl/www/website/myblog/current/public; } } server { listen 80; server_name www.blog.xiaozhumaopao.com; rewrite ^(.*)$ https://$host$1 permanent; #设置这里访问http协议 也会自动跳转到 https协议 location / { index index.html index.htm; } } server { listen 443 ssl; server_name www.report.xiaozhumaopao.com; ssl_certificate cert/3063067_xiaozhumaopao.com.pem; ssl_certificate_key cert/3063067_xiaozhumaopao.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_set_header X-Forwarded-Host $server_name; proxy_pass http://myreport; proxy_redirect off; } location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|pdf|txt|html){ root /home/zyl/www/website/myReport/current/public; } } server { listen 80; server_name www.report.xiaozhumaopao.com; rewrite ^(.*)$ https://$host$1 permanent; location / { index index.html index.htm; } }