为什么nginx proxy_pass传递给变量仅传递根URL

时间:2020-05-02 11:09:53

标签: nginx

我正在尝试实施此建议,以使我的nginx服务启动,即使上游服务不存在https://sandro-keil.de/blog/let-nginx-start-if-upstream-host-is-unavailable-or-down/

为简单起见,我删除了其他位置

gitea是我要代理的堆栈上服务的名称

因此,使用此配置,一切正常

"Day " + x
x=1
if x < 30
   display add button
   x++
elif x == 30
   display add button
   display the confirm button
   x++
elif x == 31
   display only the confirm button
else x > 31
   x = 31

但是,如果我设置这样的变量:

    server {
        # resolver 127.0.0.11 valid=30s; ## internal docker dns
        #listen   [::]:3011 default ipv6only=on; ## listen for ipv6
        listen 80;
        client_header_timeout 120s;
                client_body_timeout 120s;
                client_max_body_size 200m;

        # save logs here

        server_name sigyl.com;


        location / {
            return 301 https://$host$request_uri;
        }
    }


    server {
        resolver 127.0.0.11 ipv6=off valid=30s; ## internal docker dns
        #listen   [::]:3011 default ipv6only=on; ## listen for ipv6
        # listen 444
        listen 443 ssl;
                # this should allow large docs
        client_header_timeout 120s;
                client_body_timeout 120s;
                client_max_body_size 0;
        ssl_certificate     /etc/letsencrypt/live/sigyl.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/sigyl.com/privkey.pem;
        # save logs here
        #access_log /var/log/nginx/access.log compression;


        # Recommendations from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
        ssl_protocols TLSv1.1 TLSv1.2;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;

        # required to avoid HTTP 411: see Issue #1486 (https://github.com/moby/moby/issues/1486)
        chunked_transfer_encoding on;

        server_name sigyl.com;


        location /git/ {
           proxy_pass http://gitea:3000/;
        }

  }

所有请求仅返回根网址

https://example.com/git/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js

只返回https://example.com/git/处的内容

我该如何解决?

1 个答案:

答案 0 :(得分:0)

山姆的评论在这里解释了问题

https://serverfault.com/questions/240476/how-to-force-nginx-to-resolve-dns-of-a-dynamic-hostname-everytime-when-doing-p/973311#comment1306507_593003

所以我最终得到了

location ~ /git/(.*) {
  resolver 127.0.0.11 ipv6=off valid=30s; ## internal docker dns set
  $upstream http://gitea:3000/$1$is_args$args;
  proxy_pass $upstream;
} 
相关问题