0

我想设置一个动态代理通行证。如果我输入例如https://sub.mydomain.com/33544那么我希望代理传递给 https://10.10.10.10/33544。所以唯一改变的是$request_uri。

那么我必须如何配置位置块,它将在我的示例 33544 中使用正确的 $request_uri 重定向到https://10.10.10.10/33544,或者如果我输入 34778,那么我将重定向到https://10.10.10.10 /34778

https://sub.mydomain.com/33544 -> https://10.10.10.10/33544

https://sub.mydomain.com/34778 -> https://10.10.10.10/34778

server {
# Setup HTTPS certificates
 listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name  sub.mydomain.com;
ssl_certificate /etc/letsencrypt/live/sub.mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sub.mydomain.com/privkey.pem;

location / {

    proxy_pass https://10.10.10.10:8001/$request_uri;
    proxy_set_header Host $http_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 $scheme;
    proxy_set_header Connection "";
}
4

0 回答 0