我在那个网络服务器上有使用 nginx 的 vps,我在/etc/nginx/conf.d 上得到了 2 个 conf (host1.com,host2.com) 文件,但对同一站点有 2 个域访问权限。 这些站点采用不同的技术 1 PHP(在 88 上运行的 Apache )和 1 个 python(在 5000 上运行的 gunicorn)都可以使用这些端口从外部正确访问这两个站点。
站点 1 会议
server{
listen 80;
root /var/www/host1.com/public;
index index.php index.html index.htm;
server_name host1.com;
location / {
try_files $uri $uri/ /index.php;
}
location ~ '.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:88;
}
location ~ /'.ht {
deny all;
}
}
host2 conf
server {
listen 80;
server_name host2.com;
access_log /var/log/nginx/fundacion.log;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
提前谢谢。
- 重新启动 nginx。
- 清除浏览器缓存。