假设VPS IP为44.55.66.77,域名为mydomain.com,VPS系统为debian 9VPS上make install安装了nginx,nginx version为1.15.1,nginx运行在80端口,一开始nginx.conf是这样,...
http {
server {
listen 80;
server_name mydomain.com;
location / {
root html;
index index.html index.htm;
}
}
}
...现在想通过nginx代理其他端口实现二级域名的效果,比如more.mydomain.com指向8090端口,配置是这样,server { listen 80; server_name more.mydomain.com; location / { proxy_pass http://127.0.0.1:8090; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; root /usr/local/nginx/html; index index.html index.htm;
}
}nginx reload后访问more.mydomain.com提示找不到服务器 IP 地址。这种写法有问题吗?另外nginx添加ssl模块后如何代理?#nginx.confserver { listen 80; server_name mydomain.com;
return 301 https://$host$request_uri;
}
1 回答
慕盖茨4494581
TA贡献1850条经验 获得超11个赞
正规的server这样书写:
server {
listen 8181; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; root E:/BsConfig/zhy_webclient; index index.html; location /ma { proxy_pass http://localhost:9090; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
添加回答
举报
0/150
提交
取消