服务器配置nginx
说明:前端发布服务端口为8090,后端服务端口为8088,并且要求实现二级域名绑定到localhost:8090。
(不影响原域名xxx.com映射的80端口),等价于two.xxx.com->http://localhost:8090
开启二级域名解析
- 解析记录——添加记录
- 主机记录(如two) 记录值(如服务器地址)
配置文件地址:/opt/nginx/conf/vhost
8090.conf
server{
listen 8090;
server_name localhost;
index index.php index.html index.htm default.php default.htm default.html;
root /home/www/two/dist;
}
8090_nginx.conf(映射到原来的8090)
server{
listen 80;
server_name two.xxx.com;
index index.php index.html index.htm default.php default.htm default.html;
root /home/www/two/dist;
location / {
proxy_pass http://[服务器]:8090;
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}