我想在单个ip和端口上运行两个具有不同域的网站,我们可以在nginx中做到吗,我点击以下链接, https://serverfault.com/questions/804246/running-multiple-website-domains-on-wildfly, 我正在使用以下内容: nginx版本:nginx / 1.10.2 wildfly-10.1.0.Final 然后执行以下步骤
我正在使用以下两个域,即xyz.com和abc.com 在xyz.com.conf中,我添加了以下代码
server {
listen ip:port;
server_name xyz.com ;
access_log /var/log/nginx/xyz.com_access.log;
error_log /var/log/nginx/xyz.com_error.log warn;
location / {
# ModSecurityEnabled on;
# ModSecurityConfig modsecurity.conf;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
proxy_pass http://ip:port/;
proxy_connect_timeout 6000;
proxy_send_timeout 6000;
proxy_read_timeout 6000;
send_timeout 6000;
index index.html ;
}
和abc.com.conf具有
server {
listen ip:port;
server_name abc.com ;
access_log /var/log/nginx/abc.com_access.log;
error_log /var/log/nginx/abc.com_error.log warn;
location / {
# ModSecurityEnabled on;
# ModSecurityConfig modsecurity.conf;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Server $host;
proxy_pass http://ip:port/;
proxy_connect_timeout 6000;
proxy_send_timeout 6000;
proxy_read_timeout 6000;
send_timeout 6000;
index index.html ;
}