Reverse Proxy Traffic to Docker Container on CyberPanel

Reverse Proxy Traffic to Docker Container on CyberPanel

We’ve recently released Docker Manager.  If you are running a web application in your Docker Container you may want to reverse proxy traffic from main webserver (OpenLiteSpeed or LiteSpeed Web server Enterprise) to docker container.  This setup have few benefits, 2 of them are:

  1. Easily manage SSL from CyberPanel for the domain you are going to setup reverse proxy on.
  2. You can load balance between different containers.
  3. .. and more!

 

You might also be interesed in: HOW TO REMOVE PORT 8090 FROM CYBERPANEL

 

Step 1: Install CyberPanel and Create Website

You first need to install CyberPanel and create your website. Skip this step if you have already done so. You can also issue SSL for this website.

Step 2: Setup Reverse Proxy

We will see two examples, with OpenLiteSpeed and LiteSpeed Enterprise Web server.

With OpenLiteSpeed

Open command line and edit: /usr/local/lsws/conf/httpd_config.conf

Take note of the address line. Make sure to replace port 8080 with appropriate port (in our case our container was being mapped to port 8080 to the outside world)

Use Rewrite Rules to Proxy traffic to your Container

You can now use rewrite rules to proxy traffic to your container,  now edit rewrite rules for the domain you choose in Step 1 using the rewrite rule guide. You can use these rules:

If you want to force redirect SSL then use the following

With LiteSpeed Enterprise Web server

Let see how we can do the same with LiteSpeed Enterprise Web server. If you have installed CyberPanel Ent, you are using LiteSpeed Enterprise Web server. If you are not already on CyberPanel Ent and want to switch you can read the switch guide.

Open command line and edit: /usr/local/lsws/conf/httpd_config.xml

Paste following content:

Make sure to paste it inside <extProcessorList></extProcessorList> in the configuration file. Take note of the address line. Make sure to replace port 8080 with appropriate port (in our case our container was being mapped to port 8080 to the outside world)

Use Rewrite Rules to Proxy traffic to your Container

You can now use rewrite rules to proxy traffic to your container,  now edit rewrite rules for the domain you choose in Step 1 using the rewrite rule guide. You can use these rules:

If you want to force redirect SSL then use the following:

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: