使用NGINX将子域指向同一服务器上的目录

时间:2018-09-23 06:50:13

标签: nginx

期望的效果是将Scenario: pathMatches('/v1/binary/download') * def responseHeaders = { 'Content-Type': 'application/octet-stream' } * def Utils = Java.type('com.myco.Utils') * def response = Utils.getPdfAsByteArray() 代理传递给domain.com,将localhost:5000代理传递给sub.domain.com。这是我的子域的服务器块。

localhost:5000/sites/app

当我在浏览器中输入server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name sub.domain.com; ssl_certificate /etc/letsencrypt/live/sub.domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/sub.domain.com/privkey.pem; include snippets/ssl-params.conf; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-NginX-Proxy true; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://localhost:5000/sites/app; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade; proxy_redirect off; } } 时,它会将我重定向到sub.domain.com。我不希望/ sites / app显示在浏览器URL栏中。

1 个答案:

答案 0 :(得分:0)

我可以通过在末尾添加/来做到这一点。 proxy_pass http://localhost:5000/sites/app/;