I have a version of keycloak running on my AlmaLinux server. This service runs on port 8080. I can access it using <SERVER-IP>:8080. I however, want to access the service using mysubdomain.mymaindomain.com. This way, the user is not confronted with port-numbers, and I suppose using autoSSL is easier (I cannot get it to work on a different port).
I tried multiple things.
The first (I know, very sketchy) was rerouting using htaccess. I made a rewrite condition that looped to localhost:8080. At first glance this worked, but redirects did not work. I suppose this is, since the service thinks it runs on ‘localhost:8080’ (what it of course does), and thus redirects (on the browser side) to localhost:8080/home for example.
The second thing I tried was adding this code to the virtualhost config file.
I added this using the WHM environment in the server configuration > apache configuration > include editor. There I tried both ‘Pre Virtual Host Include’ and ‘Post Virtual Host Include’ (Originating from here).
<VirtualHost *:80>
DocumentRoot "/public_html/keycloak_public"
ServerName mysubdomain.mymaindomain.com
# Other directives here
</VirtualHost>
That did not work, I found out I had to use a proxy. So I appended the following code behind the former part. (Originating from here).
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mysubdomain.mymaindomain.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
However, when I go to mysubdomain.mymaindomain.com this still loads the empty directory, instead of the equivalent of :8080.
According to the above mentioned thread, I have to enable proxy somehow, but I did not find a way to do so in Cpanel, so I kind of assumed it was enabled (I’m sorry). Can that be the problem, or should I look somewhere else in order to fix this problem?
2
Answers
The solution turned out to be replacing the * with the server-ip!
You can setup multiple tcpip addresses in networks and proxy ip with reverse ip include 127.0.0.1 192.168.2.1.or 2.4 on same subnet with port configuration 8080 443 22 for file server included iven if you don’t use ftp. 1023port add give yourself full rights ok there’s more to say but short on time good luck