nginx as reverse proxy

nginx as reverse proxy

I’m working on dockerizing several projects with docker-compose. And, I automated checkout from git repository and building projects,
One of maven projects inherits from parent pom the url of nexus repository. And unfortunately, nexus server was moved to a new url. This fails maven build, because it can’t download artifacts from old nexus url.

While I have no time to fix nexus url in parent pom and recompile all depending projects. And while I’m rushed to run and validate my docker-compose. I’m looking for rapid solution.

We can simply use hosts to redirect old url to the new one. But in my case, it’s not possible because the old url contains a port number.

new url:

So, I use nginx as reverse proxy to solve problem:

Step1: install nginx

$ sudo apt-get install nginx

Step2: nginx configuration
create /etc/nginx/conf.d/witr.conf with following content

server {
listen 8080;
location / {
proxy_redirect off;

Step3: locally redirect server name
edit /etc/hosts and add new entry

Step4: restart nginx

service nginx restart

Finally : run my automated build. On download, maven will ask oldurl:8080. hosts will redirect to nginx. Nginx will redirect to newurl. And maven will be able to download artifacts and build will not fail.


Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see