Proxy pass and URL rewrite with upstream

Aziz Rozyev arozyev at nginx.com
Thu Dec 21 14:56:53 UTC 2017


Hi

create 4 separate upstreams for each of these apaches,

create 4 locations, within each location block proxy_pass to appropriate upstream.

avoid using sub_filters, they are mostly forrewriting bodies of html documents.

http {

# for phpadmin
upstream phpadminup {
   server phpadmin.ltda.local:80;
}

upstream whateverup {
   server whatevername.ltda.local:80;
}

server {
   listen 80;

   location /phpadmin/ {
      proxy_pass http://phpadmin;
   }
   
   location /whatevername/ {
      proxy_pass http://whatever;
   }

   ...

}



}
br,
Aziz.





> On 21 Dec 2017, at 17:09, M. Rodrigo Monteiro <falecom at rodrigomonteiro.net> wrote:
> 
> 
>  server XXX.XXX.XXX.XXX:80 fail_timeout=60;
>  server XXX.XXX.XXX.XXX:80 fail_timeout=60;
>  server XXX.XXX.XXX.XXX:80 fail_timeout=60;
>  server XXX.XXX.XXX.XXX:80 fail_timeout=60;
> }
> 
> # cat systems.ltda.local.conf
> 
> server {
>  listen 80;
>  server_name systems.ltda.local;
>  access_log /var/log/nginx/systems.ltda.local_access.log;
>  error_log /var/log/nginx/systems.ltda.local_error.log;
> 
> location /phpmyadmin {
>  proxy_pass http://wpapp/;
>  sub_filter "http://systems.ltda.local/phpmyadmin"
> "http://phpmyadmin.ltda.local";
>  sub_filter "http://systems.ltda.local/phpmyadmin/" "http://phpmyadmin.ltda/";
>  sub_filter_once off;
>  }



More information about the nginx mailing list