nginx - Nginx 反向代理抛出 404
问题描述
我是使用 Nginx 作为反向代理的新手,这是我的/etc/nginx/conf.d/default.conf
:
server {
listen 80;
location /myip/ {
proxy_pass http://checkip.dyndns.com/;
proxy_set_header Host http://checkip.dyndns.com/;
}
}
这条线/etc/nginx/nginx.conf
是活跃的:
include /etc/nginx/conf.d/*.conf;
当我访问时,我希望看到一个关于我的 IP 地址的页面http://localhost/myip/
,但我得到了 404。任何想法为什么会这样?同时http://localhost
正确显示 nginx 的欢迎页面。
有关我的环境的更多详细信息:
- 在 GCP 中清理 debian VM
- 通过安装 Nginx
sudo apt install nginx
- 服务器状态 (
sudo systemctl status nginx
) 看起来不错:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-03-08 01:27:50 UTC; 6min ago
Docs: man:nginx(8)
Process: 4237 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exite
d, status=0/SUCCESS)
Process: 3342 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCES
S)
Process: 4242 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 4239 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 4244 (nginx)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/nginx.service
├─4244 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─4245 nginx: worker process
└─4246 nginx: worker process
Mar 08 01:27:50 marqeta-proxy-test systemd[1]: Stopped A high performance web server and a reverse proxy server.
Mar 08 01:27:50 marqeta-proxy-test systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 08 01:27:50 marqeta-proxy-test systemd[1]: Started A high performance web server and a reverse proxy server.
解决方案
推荐阅读
- angular - 角度动态高图集成 - 图表组件中的响应未更新
- kubernetes - 在 Kubernetes 中运行时,Apache Storm UI 和工作人员无法解析 nimbus
- excel - 如何在Excel中删除零件编号之间的0
- php - update_batch 在 Modal 中不起作用 - 更新功能
- python-3.x - 在 Celery 中分别按 id 检索所有链式任务结果
- javascript - 反应本机图像“无法解析模块”
- python - Python:使用来自特定行的计算值将列添加到数据框
- java - Jpa 存储库保存类型参数“S”的推断类型“S”不在其范围内
- r - 更新到 R 3.5.0 后,Rstudio-server 无法启动:传输过程中发生错误
- react-native - 无法呈现一组(列表)文本