某些位置的nginx配置

时间:2019-01-21 11:23:38

标签: nginx location

我有问题。

 server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  sandbox-web.domain.com;;
        root /opt/web/myApp/;
        port_in_redirect off;
        ssl_certificate "/etc/letsencrypt/live/sandbox-domain.com/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/sandbox-domain.com/privkey.pem";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        location /web/ {
                rewrite ^/web(.*)$ $1;
                root /opt/web/myApp/;
        }

    location /job/ {
            rewrite ^/job(.*)$ $1;
    }

        location / {
                 proxy_pass        http://127.0.0.1:8080;
                 proxy_set_header Host $host;
                 proxy_set_header X-Forwarded-SSL on;
                 proxy_set_header  X-Real-IP  $remote_addr;
                 proxy_set_header  X-Forwarded-Host  $host;
                 proxy_set_header  X-Forwarded-For 127.0.0.1;
                 proxy_set_header X-Forwarded-Proto https;
                 proxy_set_header Connection "Keep-Alive";
                 proxy_set_header Proxy-Connection "Keep-Alive";
        }

它不起作用。在浏览器中,我编写了sandbox-web.domain.com/job/static/index.html,然后看到了适用于127.0.0.1:8080的页面。是的,没关系。  但是,如果我尝试检查sandbox-web.domain.com/web/,则会看到空白页,并且access.log中出现404错误。 但是,如果我评论/ job /和/位置,则我的位置/ web /可以正常工作! 为什么?

我需要什么?我需要https://sandbox-web.domain.com/web/将显示/opt/web/myApp/index.html中的页面,页面https://sandbox-web.domain.com/job/static/index.html必须将我转到127.0.0.1:8080 app(其中index.html位于/ static中/index.html)。

请帮忙!

0 个答案:

没有答案