nginx具有多个位置的子目录

时间:2015-09-02 04:06:17

标签: angularjs node.js nginx configuration webserver

我想在nginx中设置子目录。像

  1. https://example.com/(location / root / abc)
  2. https://example.com/mysite(location / root / mysite)
  3. 我当前的nginx配置是

    upstream nodeproxy{
        server 127.0.0.1:3814;
    }
    
    upstream adminproxy{
        server 127.0.0.1:3817;
    }
    
    server {
        listen               443 ssl spdy;
        server_name example.com;
        location ~* \.(css|js|json|html|jpg|png|ico|eot|svg|ttf|woff|woff2)$ {
            root /root/abc/;
        }
        location / {
            proxy_pass         http://nodeproxy;
        }
        location /admin/ {
            proxy_pass         http://adminproxy;
        }
    
        gzip on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        gzip_buffers 16 8k;
        gzip_vary on;
    }
    

    我试着这样说但是它不起作用

    upstream nodeproxy{
        server 127.0.0.1:3814;
    }
    
    upstream adminproxy{
        server 127.0.0.1:3817;
    }
    
    server {
        listen               443 ssl spdy;
        server_name example.com;
        location ~* \.(css|js|json|html|jpg|png|ico|eot|svg|ttf|woff|woff2)$ {
            root /root/abc/;
        }
        location / {
            proxy_pass         http://nodeproxy;
        }
        location /admin/ {
            proxy_pass         http://adminproxy;
        }
    
        gzip on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        gzip_buffers 16 8k;
        gzip_vary on;
    }
    server {
        listen               443 ssl spdy;
        server_name example.com/mysite;
        location ~* \.(css|js|json|html|jpg|png|ico|eot|svg|ttf|woff|woff2)$ {
            root /root/mysite/;
        }
        location / {
            proxy_pass         http://nodeproxy;
        }
        location /admin/ {
            proxy_pass         http://adminproxy;
        }
    
        gzip on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        gzip_buffers 16 8k;
        gzip_vary on;
    }
    

0 个答案:

没有答案