0

I'm trying to proxy pass url with nginx like this :

server {
    listen       9998;
    error_log logs/error_sonar.log debug;

    location /sonar/ {
          proxy_pass http://192.168.0.23:9000/;
    }

}

but with this configuration, if i call : http://localhost:9998/sonar/ proxypass work but sonar try to do 'GET /css/sonar.877c3354.css' instead of 'GET /sonar/css/sonar.877c3354.css'

how can i say to nginx to add prefix /sonar in all return proxiex url?

I have try

server {
    listen       9998;
    error_log logs/error_sonar.log debug;

    location / {
          proxy_pass http://192.168.0.23:9000/;
    }

}

and all work fine, but what i wan't to do is to have /sonar, /nexus, /otherapplication on same port.

Does i need to change sonar config to have context /sonar too? And do it for all applications in the same case?

thanks by advance.

  • Remove trailing slash on your `proxy_pass` directive in your first config example and it will work as you expected. See [this](https://stackoverflow.com/questions/53649885/a-little-confused-about-trailing-slash-behavior-in-nginx/53650827#53650827) answer for more details. – Ivan Shatsky Dec 13 '18 at 16:35
  • Just checked on a live server, it must work. Are you sure you did not forget to reload your nginx configuration? Once again, your location block must contain `location /sonar/ { proxy_pass http://192.168.0.23:9000; }` – Ivan Shatsky Dec 13 '18 at 16:55
  • yes i have reload my nginx and the configuration is like you say. the proxies application (sonar) loose /sonar/ context. – Mançaux Pierre-Alexandre Dec 14 '18 at 08:16

0 Answers0