I
I
Igor S2016-08-23 12:53:50
Nginx
Igor S, 2016-08-23 12:53:50

nginx. How to give statics through proxy_pass?

Firework!
There is a pretty simple configuration

location / { 
        proxy_pass http://172.16.18.20:7777/;
    }   

    location /i {
        proxy_pass http://172.16.18.20:7777/i/;
    }   

    location ~* /mw-config/ {
             return 444;                                                                                                                 
    }   
         
    location ~* /maintenance/ {
             return 444; 
                  
    }   

    location ^~ /wiki {
        try_files /exwiki/$uri /exwiki/$uri/ @exwiki;
    }   

    location @exwiki {
        rewrite /wiki(.*) /exwiki/index.php;
    }   

    location ~* \.php {
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 512k;
        fastcgi_pass unix:/var/run/php-fpm/www.sock;

    }

    location ~* \.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$ {
        access_log      off;
        expires           max;
           
    }

location /i also contains static that should be given when accessing the site root, instead nginx tries to take it from the local ROOT.
Tell me, how can I organize an exception so that when accessing the wiki , the statics would be taken locally, and when accessing / , the statics would be taken from a remote server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor S, 2016-08-23
@xarek1986

I asked myself, I will answer. You need to tell NGINX not to go further when /i is found. This is done by the method

location ^~ /i{
    proxy_pass ......
}

Read mana gentlemen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question