目标:一个nginx配置主域名和多个二级域名,二级域名指向不同的工程/端口或静态资源文件:
www.yuming.com
2ji.yuming.com
配置如下:
upstream local80{
server localhost:8080;
}
server {
listen 80;
server_name www.yuming.com yuming.com;
location / {
proxy_pass http://local80/warname/;
proxy_cookie_path /warname /;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /warname/ {
proxy_pass http://local80/warname/;
proxy_cookie_path /warname /;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
#2ji
server {
listen 80;
server_name 2ji.yuming.com;
location / {
root /www/2ji;
}
}
配置nexus二级域名时出现
There was an error communicating with the server: request timed out.
问题,在location中添加 如下配置
proxy_set_header Host $host:$server_port;