nginx - Node.js 应用程序使用服务器 IP 但不使用域名
问题描述
Node.js 应用程序在端口 80 上运行良好(使用 PM2 和 Nginx)并且可以很好地浏览服务器 IP。但是通过域它不起作用[无法访问此站点]。在 ping 域时可以看到响应中的服务器 IP。
这是我使用的 Nginx 配置:
location / {
proxy_pass "http://127.0.0.1:8000";
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;
}
解决方案
您需要server_name
在 Nginx 配置中使用声明。
server_name example.org www.example.org;
推荐阅读
- javascript - 仅返回从 fancytree 过滤的树
- python - 如何使用 plotly 在单个图中创建两个表?
- spring-integration - 手动注册spring集成流和多个子流
- python - 如何迭代到熊猫数据框列并删除特定行?
- matlab - 我可以删除占位符变量以在 Matlab 中节省内存吗?
- jquery - 单击按钮后重新关注输入
- mysql - 使用 REGEXP 在 MySQL 5 中返回特定的捕获组/子字符串
- ruby-on-rails - 具有多个不同ID的表单,如何保存
- excel - 制作列表重置子例程不删除总计行或其包含的公式
- windows - 如何在命令提示符下安装 PolyML