进行Nginx的反向代理的时候出现的坑
作者:互联网
需要在C:/Windows/System32/drivers/etc/hosts:
进行域名的代理,注意之间的空格:
127.0.0.1 localhost
127.0.0.1 manage.leyou.com
127.0.0.1 api.leyou.com
127.0.0.1 www.leyou.com
这里一定要测试一下
ping manage.leyou.com
ping api.leyou.com
这样等于nginx反向代理了我们的端口号的配置
然后编辑 conf/nginx.conf文件加上server的配置:
server {
listen 80;
server_name manage.leyou.com;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
#this is the ip address
proxy_pass http://127.0.0.1:9001;
proxy_connect_timeout 600;
proxy_read_timeout 600;
}
}
server {
listen 80;
server_name api.leyou.com;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://127.0.0.1:10010;
proxy_connect_timeout 600;
proxy_read_timeout 600;
}
}
标签:set,header,0.1,代理,Nginx,leyou,反向,proxy,com 来源: https://blog.csdn.net/houzhicongone/article/details/120648277