Help with Nginx_Apache Reverse Proxy for Subdomains

jstrauss

Verified User
Joined
Jun 1, 2023
Messages
16
Location
Austria
Hello, I switched due a server reinstallation from Apache to Nginx with Apache.
On Apache I used the httpd.conf CUSTOM-Tokens Section to achieve the Reverse Proxy to Docker-Apps on subdomains.
Like this:
Code:
|*if SUB="docker"|
ProxyPass /.well-known/ !

Header always set Access-Control-Allow-Origin "*"

SSLEngine On
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt.combined
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key

ProxyPreserveHost on
ProxyPreserveHost On
ProxyRequests Off

# allow for upgrading to websockets
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule ^/?(.*) ws://IP:9000/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule ^/(.*)           http://IP:9000/$1 [P,L]

ProxyPass "/" "http://IP:9000/"
ProxyPassReverse "/" "http://IP:9000/"

|*endif|

But now on Nginx with Apache I think it's the best to get Nginx to do all proxien-Stuff because it's faster in proxien and so on and also in front of Apache.
I tried the solution from: "https://help.poralix.com/articles/nginx-to-proxy-requests-to-custom-port-in-directadmin"

But this does only work on DOMAINS and i don't want to create every subdomain as domain as it's not meant to be and also exceeds the limit of my domains.

I tried this:
Code:
|*if SUB="docker"|
|?PROXY_PASS=http://127.0.0.1:9000/|
|*endif|

in nginx proxy conf in CUSTOM2 of Httpd-Configurations in the Web-UI, but this doesn't work.

So as you notice my plan is to reverse proxy subdomains to docker/local ports without much effort and with CUSTOM-Tokens ore something similar. It should also be possible to define some other parameters like websockets and some other nginx/webserver stuff.

Thanks for any help!
 
Back
Top