rewrite URL

Constantine A. Murenin cnst++ at FreeBSD.org
Sat Jul 4 18:53:31 UTC 2015


On 2015-07-04 11:38, Philipp Kraus wrote:
> Hello,
>
> I try to use Nginx as a proxy (for SSL) on a Jetty server. The Jetty application should be accessed by a subdirectory of my Nginx. I have setup this location configuration:
>
> location /myapp {
>
>      proxy_pass              http://localhost:8112;
>
>      proxy_set_header        X-Forwarded-Host    $http_host;
>      proxy_set_header        X-Forwarded-Proto   $scheme;
>      #proxy_set_header        X-Real-IP           $remote_addr;
>      proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;
>      proxy_http_version      1.1;
>      proxy_set_header        Upgrade             $http_upgrade;
>      proxy_set_header        Connection          "upgrade";
>      client_max_body_size    650M;
>
> }
>
> The Jetty server runs under http://localhost:8112, if I change the „location /myapp“ to „location /„ everything works fine. The Jetty server returns URLs with the base URL /, so on this configuration CSS / JSS files are not found.
> How can I rewrite the URLs, so that all files are found within the directory /myapp ?
>
> Thanks
>
> Phil

Hi Phil,

You should specify a URI (e.g., a trailing slash) in the URL specified 
by the proxy_pass directive:

 > location /myapp {
 >
 >      proxy_pass              http://localhost:8112/;
...

See http://nginx.org/r/proxy_pass for more info.

Cheers,
Constantine.



More information about the nginx mailing list