nginx - 带有反向代理的Nodejs
问题描述
我目前正在使用 NodeJs over Nginx 来托管网站,因为我已经意识到 Nginx 的端口冲突,我已经更改了配置文件,我现在可以访问 localhost。但问题是该网站不再与托管在端口 3000 上的网站相同(我将 NodeJs 源设置为监听)它真的很挣扎,我真的希望有人能给我一个解决方案。
配置代码如下
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
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;
}
解决方案
推荐阅读
- perl - ExtUtils::MakeMaker 如何执行外部makefile
- ios - Swift 4 使用 CodableFirebase 和自定义类处理来自 Firestore 的 nil 值
- python - 如何在 Pytorch 中可视化网络?
- python - connection.recv 无法读取缓冲区
- android - 使用 Picasso 将图像从 firebase 加载到 CircleImageView
- php - Laravel 5.6:POST 路由的分页在除第一个之外的所有链接上提供空白页
- neo4j - 如何在解析器中设置字段参数
- html - Bootstrap 4 最小页面/侧边栏高度
- button - 如何根据条件将禁用按钮变为启用按钮
- python - 如何使用 BeautifulSoup 获取页面上的所有外部链接?