Redirect to different port when url start with a specific path/string

Hi all! I created a website using WordPress and next.js, all using Docker. My frontend part (next.js) is exposed on port 80 so I can see my site when I write the correct URL. Wordpress is exposed to port 8080 and to access my admin part I need to write MY_IP:8080/wp-admin/.

I would like to find a way to see the content of MY_IP:8080/wp-admin/ every time I write the URL of my website like this MY_URL/wp-admin/ but of course, continuing to see the URL with the right name of my site (MY_URL/wp-admin/) and not with MY_IP:8080/wp-admin/.

Of course, I need this logic also for any subfolder/file when the path starts with wp-admin (i.e. MY_URL/wp-admin/post.php?post=320&action=edit).

Does somebody know what I need to check for making this possible?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


What you could do is install Nginx and use it as a reverse proxy for your Wordpress website which is running inside your Docker container on port 8080.

The Nginx reverse proxy that you could use, should look something like this:

server {
  listen 80;
  server_name; # change this

  # global gzip on
  gzip on;
  gzip_min_length 10240;
  gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
  gzip_disable "MSIE [1-6]\.";

  add_header Cache-Control public;

  location / {
    proxy_pass; # change this
    proxy_buffering on;
    proxy_buffers 12 12k;
    proxy_redirect off;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;


Also, you could take a look at this answer here on how to host multiple Docker containers one server with Nginx:

Hope that this helps! Regards, Bobby