proxy_pass to specific location

oamakarov nginx-forum at nginx.us
Thu Apr 16 16:42:15 UTC 2015


Hello everyone!
I have next configuration of my nginx:
## first backend ##
upstream first {
     server 192.168.1.12:8080;
     server 192.168.1.13:8080;
     sticky;
        }
## second backend ##
upstream second {
     server 192.168.1.14:8080;
   }

## config ##
server {
        listen 192.168.1.11:443 ssl spdy;
        server_name domain.com

        ssl                 on;
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers
kEECDH+AES128:kEECDH:kEDH:-3DES:kRSA+AES128:kEDH+3DES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv2;
        ssl_prefer_server_ciphers on;
        ssl_certificate     /etc/nginx/ssl/domain.crt;
        ssl_certificate_key /etc/nginx/ssl/domain.key;
        ssl_session_cache   shared:SSL:10m;
        ssl_session_timeout 10m;

        set         $root_path '/var/www/domain';
        root        $root_path;

        access_log  /var/log/nginx/domain.access.log main;
        error_log   /var/log/nginx/domain.error.log warn;

        index index.html
        charset utf-8;

        location / {
                proxy_set_header Accept-Encoding "";
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-By $server_addr:$server_port;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_pass http://first;
                ## send traffic to SECOND backend if ip is 1.2.3.4 ##
                if ( $remote_addr ~* 1.2.3.4 ) {
                        proxy_pass http://second;
               }
                proxy_next_upstream error timeout invalid_header http_500
http_502 http_503 http_504;

        location /notification {
                proxy_pass http://first/notification;
        }
}

If I go through backend: http://192.168.1.12(13):8080/notification - I'm
getting the correct answer. But  when I go to 
https://domain.com/notification a have 404 error and nothing proxied. 
Please help me to get right conf of NOTIFICATION location.
Thank you!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,258115,258115#msg-258115



More information about the nginx mailing list