0

my nginx.conf

worker_processes 1;
events {
    worker_connections 1024;
}

http {
    upstream app_servers {
        server 127.0.0.1:5000;
        server 127.0.0.1:5001;
    }

    server {
        listen 6200;
        server_name test;
        add_header X-GG-Cache-Status $upstream_cache_status;
        include rewrite.conf;
    }
}

and my rewrite.conf in the same folder as that

location = / {
    rewrite ^/some-custom-destination/?$ /destination/detail?id=33;
    proxy_pass http: //app_servers;
    proxy_intercept_errors on;
    error_page 400 404 /;
    error_page 500 502 503 504 /error.html;
    location = /error.html {
        root /etc/nginx/;
    }
}

How can I fix that?

Help, please. Thank you.

  • when I use nginx -s reload command getting that error : nginx: [emerg] unknown directive "location" in /etc/nginx/rewrite.conf:1 – Onur Vatan May 17 at 8:57
  • I don't know how you are getting that specific error. When I test your configuration, the proxy_pass fails because of a spurious space, and the second location fails because it's nested within an exact match location block. – Richard Smith May 17 at 10:54
  • You can't have nested location =. It's meaningless. – Alexey Ten May 17 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.