首页 > 解决方案 > 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 的欢迎页面。

有关我的环境的更多详细信息:

● 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.

标签: nginxreverse-proxynginx-reverse-proxy

解决方案


推荐阅读