Nginx – How to reverse proxy a URL path

bitnaminginxowncloud

I have a owncloud server running at owncloud.example.com/owncloud
Its a bitnami install and requires me to access it via the /owncloud path. I have the thing reverse proxied through nginx but it takes me to the bitnami page first from which I have to take a link to the actual path. Or I have to access the url via the complete path. How do I setup my reverse proxy to avoid this. This is my rudimentary setup to just play around with.

server {
    listen   80;
    server_name owncloud.example.com;


    location / {

    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass http://192.168.1.139:83/;

 }

}

Right now the reverse proxy will take me to owncloud.example.com. I need it to take me to owncloud.example without hitting a redirect loop.

Best Answer

Change you proxy_pass to following:

proxy_pass http://192.168.1.139:83/owncloud;

It should do the trick. If that's not what you want please describe more carefully.