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/)을보십시오. –