Nginx删除反向代理上的子目录路径

时间:2020-03-29 22:26:20

标签: spring-boot nginx nginx-location nginx-reverse-proxy

我试图将mydomain.com/api/映射到我的Spring应用程序上的端口9292,该端口通常可以工作,但是我需要从代理url中删除api /。 我知道,我可以将/ api /作为上下文路径添加到Spring应用程序中,这不是一个选择。

Nginx Conf:

location /api/ {
          proxy_pass http://127.0.0.1:9292/;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto "https";

          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";

          proxy_connect_timeout 1d;
          proxy_send_timeout 1d;
          proxy_read_timeout 1d;
        }
        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        }
        location ~ /\.ht {
                deny all;
        }

0 个答案:

没有答案