Categories
Tutorial

CyberPanel: Reverse Proxy to Docker Container

How to Reverse Proxy Traffic to Docker Container on CyberPanel:
https://community.cyberpanel.net/t/reverse-proxy-traffic-to-docker-container-on-cyberpanel/30644

Setup Reverse Proxy:
Open and edit: /usr/local/lsws/conf/httpd_config.conf

extprocessor dockerbackend {
  type                    proxy
  address                 127.0.0.1:8080
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

Here “dockerbackend” is a referance name to use later and “8080” is the docker container port.

Use Rewrite Rules to Proxy traffic to your Container:
Now create a website and create the following a .htaccess rewrite rule there.
REWRITERULE ^(.*)$ HTTP://dockerbackend/$1 [P]

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

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
REWRITERULE ^(.*)$ http://dockerbackend/$1 [P]