Wednesday, January 4, 2012

nginx: simple proxy_pass usage

Problem: send incoming requests containing "/trybe" in the URL on the "enkomion" hostname to the  Trybe REST server locally hosted on tomcat (which is listening on port 8080).

Example:
input="http://enkomion/trybe/..."
output="http://localhost:8080/trybe/..."
(simply have to convert enkomion to localhost:8080 in the hostname part of the URL, but only for /trybe/ location)

Solution:
server{

        ...

        server_name localhost enkomion

        ...

        location /trybe {     
  proxy_pass http://pts;
        }

        ...
}

No comments: