当前位置:首页 > 编程笔记 > 正文
已解决

nginx 代理域名到另外一个域名

来自网友在路上 11058105提问 提问时间:2023-09-21 20:19:54阅读次数: 105

最佳答案 问答题库1058位专家为你答疑解惑

nginx 代理域名到另外一个域名

server {listen	80;server_name  原域名;location / {  #return 301 http://新域名$request_uri;  # 重定向到新域名  proxy_pass	http://新域名/;proxy_redirect	http://原域名/ http://新域名/;} }
server {listen       80;server_name  新域名;# websocket代理#location /webSocket/chat {#	 proxy_pass  http://xxx.xxx.com/webSocket/chat;#    proxy_set_header Host $host;#     proxy_set_header Upgrade 'websocket';#     proxy_set_header Connection 'Upgrade';#	 proxy_connect_timeout 4s;#	 proxy_read_timeout 7200s; #两个小时#	 proxy_send_timeout 12s;#}location / {		proxy_pass	http://localhost:8080;root   html;index  index.html index.htm;proxy_set_header   Host             $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;}}

注意:用return,可以重定向到新域名的页面,但是请求方法是有问题的

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"nginx 代理域名到另外一个域名":http://eshow365.cn/6-10937-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!