nginx反向代理重定向到错误的域 [英] nginx reverse proxy redirecting to wrong domain

查看:468
本文介绍了nginx反向代理重定向到错误的域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用本教程

I'm using this tutorial nginx reverse proxy tutorial to setup a node site with nginx. this is what my nano /etc/nginx/conf.d/mydomain.com.conf looks like

server { 
listen 80;
server_name mydomain.com;
location / { 
proxy_pass http://localhost:3000; 
proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection 'upgrade'; 
proxy_set_header Host $host; 
proxy_cache_bypass $http_upgrade; 
} 
}

问题在于,当我访问我的域时,它会重定向到我在同一服务器上设置的另一个域.我使用

The problem is that when I visit my domain, it's redirecting to another domain that I have setup on the same server. I setup that other domain (a static page) using an nginx virtual hosts tutorial that uses server blocks. One difference I noticed is that the nginx reverse proxy tutorial doesn't do any of this symlinking between sites available and sites enabled which the virtual hosts tutorial does with the server blocks files. The virtual hosts tutorial instructs the reader to create server block files and then enable them like this

sudo ln -s /etc/nginx/sites-available/demo /etc/nginx/sites-enabled/demo

使用Nginx设置反向代理时,我需要做任何事情来启用配置文件吗?如果不是,您知道为什么它重定向到另一个域吗?

Do I have to do anything to enable the config file when setting up a reverse proxy with nginx? If not, do you know why it's redirecting to the other domain?

/etc/nginx/conf.d/mydomain.com.conf

推荐答案

问题是/etc/nginx/conf.d/mydomain.com.conf尚未复制到

The problem was that /etc/nginx/conf.d/mydomain.com.conf hadn't been copied into

/etc/nginx/sites-enabled

这篇关于nginx反向代理重定向到错误的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆