关于LEMP配置的问题以及如何重定向到NodeJS请求到NGINX

时间:2014-03-06 08:14:03

标签: node.js nginx

我使用 NodeJS Ubuntu 上配置了 LEMP服务器,但我在浏览器上收到以下错误。

"The page you are looking for is temporarily unavailable

请稍后再试。“我如何重定向到 NodeJS 请求 NGINX 。请你帮我解决这些问题。

1 个答案:

答案 0 :(得分:0)

如果NGINX通过PHP-FPM(FastCGI Process Manager)工作,那么您可以取消注释PHP的重要部分是文件中定义的默认vhost中的位置〜\ .php $ {}节

  

vi / etc / nginx / sites-available / default

喜欢

[...]

location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }

[...]

对于NodeJS,您还可以修改相同的Vhost文件

  

vi / etc / nginx / sites-available / default

并在位置〜\ .php $ {}下添加行

[...]
        location /testapp/ {
        proxy_pass  http://localhost:3000/;
        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

将端口转发到Node.js应用程序
Now you can access the your page by this URL http://localhost/testapp/ instead of http://localhost:3000/

希望它会对你有用