nginx - 如何通过 nginx 反向代理在 GCP 上配置从外部 ip 到内部 ip 的访问?
问题描述
无法通过外部 IP 连接到应用程序。
我在 GCP 的 vm 实例(CentOS 7)上启动了 gerrit 代码审查应用程序。它适用于http://localhost:8080,我无法通过外部 IP 连接到它。我也尝试创建 NGINX 反向代理,但可能我的配置错误。顺便说一句,安装 NGINX 后,启动页面显示在外部 ip 上。
# nginx configuration /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
auth_basic "Welcomme to Gerrit Code Review Site!";
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
gerrit.config
[httpd]
listenUrl = proxy-http://127.0.0.1:8080/
解决方案
在 /etc/hosts 127.0.0.1 internal.domain 中添加一行
更新代理配置 proxy_pass http://internal.domain:8080;
它适用于我
推荐阅读
- linux - 无法解决此问题:错误 [EINVAL 无效参数] mq_open
- c# - UWP 应用程序因错误而崩溃 - 该进程无法访问该文件,因为它正被另一个进程使用
- angular - Azure Maps Control 导致 Angular Universal SSR 错误
- linux - 当我们在 linux 中通过 connect 函数调用得到错误 ENETUNREACH
- r - 码本包中的标记图
- jupyter-notebook - 在 PyCharm 托管的 Jupyter 服务器中处理“超出 IOPub 数据速率”
- amazon-redshift - Redshift ROW_ID 列换行?
- javascript - 出现错误所需的请求部分“logoURL”不存在
- mysql - Woocommerce 外部链接损坏(现在按钮已替换为“添加到购物车”)
- python - 问:无法在 MacOS 上启动 Jupyter Lab