繁体   English   中英

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

[英]Issue on LEMP configuration and how can i redirect to NodeJS request to NGINX

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

"The page you are looking for is temporarily unavailable

请稍后再试。”我怎样才能重定向到的NodeJS请求NGINX。可以请你帮我,我怎么能理清这些问题。

如果NGINX通过PHP-FPM(FastCGI进程管理器)工作,那么您可以取消注释PHP的重要部分是文件中定义的默认虚拟主机中的位置〜\\ .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/

希望它将为您服务

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM