nginx - nginx 虚拟主机在本地工作但不在全球范围内工作
问题描述
当我在本地主机上使用 curl 它的工作。
root@ip-10-87-3-236:/etc/nginx# curl -o /dev/null -s -w "%{http_code}\n" http://localhost/ib
Output :
200
但是当我通过互联网连接到浏览器时,我得到了
Not Found
The requested resource was not found on this server.
nginx 配置:
server {
listen 80;
server_name localhost;
location /ib {
proxy_pass http://localhost:3000; #whatever port your app runs on
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;
}
}
请在此处提供帮助或分享任何可能非常有用的文档
谢谢
解决方案
您已指定localhost
为您的server_name
. 如果您想通过 Internet 和/或使用您选择的域名进行这项工作,例如example.com
将 设置server_name
为域名。这将解决您的问题。
参考:https ://nginx.org/en/docs/http/ngx_http_core_module.html#server_name
推荐阅读
- html - 我希望在我的网页背景中播放 YouTube 音频
- flutter - 重新加载颜色容器以清除 Flutter 中的 TextField
- hyperledger-fabric - 如何从 docker 容器上运行的客户端应用程序连接到 Fabric 网络
- sql - 仅检索每个学生的第一行
- ansible - Ansible:在另一个循环中引用的循环变量
- javascript - 箭头函数未定义
- java - 如何忽略 Xpath 中的特定字符?
- angular - Angular Overlay 将不存在的 dom 元素称为覆盖容器
- javascript - Chainlink 外部适配器对 Spotify 进行 API 调用时出现问题
- database - 安装 mongoose 和 Mongodb 时出错