0

I have multiple tools running on different ports on the same machine. Jenkins, gitea, etc. I have a CNAME setup for each. jenkins.foo.bar, gitea.foo.bar, etc. I'm trying to set it up so when I go to jenkins.foo.bar it actually loads foo.bar:8080 and gitea.foo.bar loads foo.bar:3000. So far I've tried to setup a proxy pass and reverse proxy pass with httpd 2.4.6.

<VirtualHost gitea.foo.bar:80>
ServerName gitea.foo.bar
ServerAlias gitea.foo.bar gitea.foo
ProxyPreserveHost On
ProxyPass / foo.bar:3000/
ReverseProxyPass / foo.bar:3000/
</VirtualHost>

EDIT: The actual question... Originally I was get Error 403 unavailable. Now when I go to gitea.foo it's redirected to foo.bar:3000 correctly. gitea.foo.bar loads foo.bar's index and is not caught by the proxy.

Part 2: Is it possible to keep gitea.foo in the address bar and not display the redirected address?

=========================

EDIT (The solution): Big thanks to @GeraldSchneider

SeLinux was blocking proxy pass. Note this took 20 minutes to complete

setsebool -P httpd_can_network_connect 1

Move ssl.conf out of the way since it was listening on 443.

mv /etc/httpd/conf.d/ssl.conf /etc/hhtpd/conf.d/ssl.conf.bak

Add the following to /etc/httpd/conf/httpd.conf

Listen 443 https
<VirtualHost *:80>
ServerName gitea.foo.bar
Redirect / httpd://gitea.foo.bar:3000
</VirtualHost>

<VirtualHost _default_:443>
ServerName gitea.foo.bar
SSLEngine On
SSlProxyEngine On
SSLCertificateFile /etc/PATH/TO/gitea.foo.bar.pem
SSLCertificateKeyFIle /etc/PATH/TO/gitea.foo.bar.key
ProxyPass / https://gitea.foo.bar:3000/
ProxyPassReverse / https://gitea.foo.bar:3000/
</VirtualHost>

Edit gitea config /etc/gitea/app.ini

[server]
PROTOCOL = https
ROOT_URL = https://gitea.foo.bar
CERT_FILE = /etc/PATH/TO/gitea.foo.bar.pem
KEY_FILE = /etc/PATH/TO/gitea.foo.bar.key

1 Answers1

1

Your Apache configuration is fine, the problem is your backend.

Your backend is configured for the URL foo.bar:3000, so it redirects there when it is NOT reached via this URL.

You need to configure your backend servers for the new URL. How to do this is different on every application server, a common name for such a setting is base url or something like this. Read the documentation of your backend servers (jenkins, gitea, etc ...) on how to do that.

Examples:

Jenkins: https://stackoverflow.com/questions/11221238/what-does-jenkins-url-means-in-configuration-settings

Gitea:

set [server] ROOT_URL = http://git.example.com/git/ in your configuration.

From: https://docs.gitea.io/en-us/reverse-proxies/

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89