提供静态文件以反转代理路径nginx

时间:2017-07-12 10:41:30

标签: angularjs nginx reverse-proxy

我想使用带有angularjs的预留代理(nginx)在myurl.com/app1/下运行我的应用程序。但是,当我致电myurl.com/app1/时,我只获得index.html,静态文件仍然指向myurl.com/assets/而不是myurl.com/app1/assets/

upstream smileyface {
        server localhost:8081;
}

server {
    access_log /var/log/nginx/myurl_access.log;
    error_log /var/log/nginx/myurl_error.log warn;
    # SSL configuration

    listen 443 ssl;
    listen [::]:443 ssl;

    include snippets/ssl-myurl.com.conf;
    include snippets/ssl-params.conf;

    index index.html index.htm index.nginx-debian.html;

    server_name myurl.com www.myurl.com;

    location /app1/ {
            index index.html;
            alias /angular-app-folder/;
            proxy_pass http://smileyface/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    location ~ /.well-known {
            allow all;
    }
}

0 个答案:

没有答案