示例
#http节点中可以添加多个server节点server{#听443端口listen 8443 ssl;#对应的域名,把www.shentuzhiganga.top改成你们自己的域名就可以了server_name zstu.shentuzhiganga.top;#从腾讯云获取到的第一个文件的全路径ssl_certificate /opt/etc/ssl/4084041_shentuzhigang.top.pem;#从腾讯云获取到的第二个文件的全路径ssl_certificate_key /opt/etc/ssl/4084041_shentuzhigang.top.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;#这是我的主页访问地址,▒.▒为使用的是静态的html网页,所以▒.▒接使用location就可以完成了。location /jwglxt {proxy_set_header Host $host;proxy_pass http://jwglxt.;}location ~ /zftal* {proxy_pass http://jwglxt.;}location /ykt {proxy_set_header Host $host;rewrite ^/ykt/(.*)$ /$1 break;proxy_pass http://ykt.;proxy_redirect http://ykt./ https://zstu.shentuzhigang.top/ykt/;proxy_redirect https://zstu.shentuzhigang.top/ https://zstu.shentuzhigang.top/ykt/;proxy_redirect http://zstu.shentuzhigang.top/ https://zstu.shentuzhigang.top/ykt/;}location /stu {proxy_set_header Host $host;rewrite ^/stui/(.*)$ /$1 break;proxy_pass http://stu.;}location / {#文件夹root /usr/share/nginx/html;#主页文件index index.html;}}
参考文章
nginx重定向
nginx 之 proxy_redirect详解
nginx之location规则及地址重写