0
它重定向每个人,包括my.personal.ip.address,但它只能将除我之外的其他人重定向到博客。当我将它放在默认的nginx文件中时它正在工作,但现在我试图让我的节点应用程序运行,我不确定放置if语句的位置以及为什么它不起作用。Nginx重定向规则不适用于节点应用程序
# the IP(s) on which your node server is running. I chose port 3000.
upstream mywebsite {
server 127.0.0.1:3000;
keepalive 8;
}
# the nginx server instance
server {
listen 0.0.0.0:80;
server_name mywebsite.ca mywebsite;
access_log /usr/share/nginx/html/yourdomain.log;
# pass the request to the node.js server with the correct headers
# and much more can be added, see nginx config options
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://mywebsite/;
if ($remote_addr != my.personal.ip.address){
rewrite^http://blog.mywebsite.ca;
}
proxy_redirect off;
}
}
我甚至不知道我的节点应用程序是否显示。我遇到的问题是,由于if语句,我不应该被重定向到博客,但我是。 –
对不起,再读一遍,我明白了。也许最好做的是在NGINX上进行调试。例如:'error_log/path/to/log debug;'并且看到[IfIsEvil](https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/) –