Apache reverse proxy leading to a blank page - apache

I have a youtrack instance running on port 8080 of my webserver. The domain that is used to access the server is subdomain.maindomain.com
Now I want youtrack to be accessed through subdomain.maindomain.com/youtrack instead of subdomain.maindomain.com:8080.
However, when setting up my reverse proxy config, the url leads to a blank page.
My youtrack.conf looks like the following:
<VirtualHost *:80>
ServerName subdomain.maindomain.com
ProxyPreserveHost On
DocumentRoot /var/www/html
ProxyPass /youtrack/ http://subdomain.maindomain.com:8080/
ProxyPassReverse /youtrack/ http://subdomain.maindomain.com:8080/
</VirtualHost>

Related

Proxy Request if ServerName does not match

I have Ubuntu 20.04 machine and in that I have installed Apache server for handling the web requests. I want to run multiple websites on my single machine.
What I want is when request is coming from specific url then apache should load the specified directory for that url. If request is not coming from that specific url then request should be proxied.
To achieve this, I tried two methods but none worked
Method One
I created two virtual host files, one for request for proxy and another for pointing to a DocumentRoot when url matches
vs1.conf
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>
vs2.conf
<VirtualHost *:80>
ServerName abc.example.com
ServerAlias abc.example.com
DocumentRoot /var/www/my-website
</VirtualHost>
When I use above method, all the request points to /var/www/my-website as DocumentRoot but this should only be the case when url is abc.example.com. It is like the vs1.conf not even called and only vs2.conf file controlling the request.
Method Two
In this method, I decided to use just one virtual host file which looks like below
<VirtualHost *:80>
ServerName abc.example.com
ServerAlias abc.example.com
DocumentRoot /var/www/my-website
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>
In this case, when request is coming from abc.example.com then I see a blank page as if this request is not being handled. But when request is coming from url other than abc.example.com then they are proxied correctly.
So now I am clueless about how my configuration file should look like?

Apache Virtual Hosts serves the vhost NOT matched

I set up an Apache Server with two Virtual Hosts and it has a very weird behaviour. I have a normal webserver, that should be server in all cases, except given the case, that the domain name is "biblio.name" or "biblio-intra.name", which should be redirected to a virtual machine located on my laptop, serving another webservice on Linux. On my laptop I use xampp for the Apache Server. I have the following "httpd-vhosts.conf" in my apache/conf/extra folder:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName sis.name/
ServerAlias *
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass "/" "http://127.0.0.1:8080/"
ProxyPassReverse "/" "http://127.0.0.1:8080/"
ServerName biblio.name/
ServerAlias biblio-intra.name/
</VirtualHost>
So I expected it to redirect all requests to "biblio.name" and serve the rest as normal. However, it didn't!
When I enter my static ip-adress (assigned from the router) in the browser, I get served htdocs as normal, perfectly fine. When I enter biblio.name:8080 I also get normally served the virtual machine as expected (obviously, since 8080 automatically uses the redirect rule of the virtual machine.) However, when I type "sis.name" it redirects me to the virtual machine and when I type "biblio.name" it serves me from the htdocs.
I never experienced a behaviour like that and I don't get, why it serves the opposite host of the one supposed to.
Am I missing something?
For some reason I don't know (anymore), all my apache vhost configurations have the same value for ServerName and ServerAlias. Also the / in it seems odd. You can try listing biblio-intra.name as second option, but it should at first repeat the value from ServerName:
<VirtualHost *:80>
ServerName sis.name
ServerAlias sis.name
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
<VirtualHost *:80>
ServerName biblio.name
ServerAlias biblio.name biblio-intra.name
ProxyPreserveHost On
ProxyRequests Off
ProxyPass "/" "http://127.0.0.1:8080/"
ProxyPassReverse "/" "http://127.0.0.1:8080/"
</VirtualHost>

Reverse proxy through Apache with Docker GitLab

I have set up the following VirtualHost in my httpd.conf
<VirtualHost *:80>
ProxyRequests On
ProxyPreserveHost On
ProxyPass /gitlab http://190.22.22.40:6060/gitlab
ProxyPassReverse /gitlab http://190.22.22.40:6060/gitlab
</VirtualHost>
EXPECTED
When I try to load the URL, http://190.22.22.40/gitlab, I want to go to the actual GitLab page to sign in as a new user
ACTUAL
I am redirected to a blank page with the url http://190.22.22.40/users/sign_in
QUESTION
How can I go to the login page with the URL http://190.22.22.40/gitlab and NO port specified in the URL?
Gitlab do not use context to separate multiple application as there is only one.
You need to proxy pass "/" and not "/gitlab" eg:
<VirtualHost *:80>
ProxyRequests On
ProxyPreserveHost On
ProxyPass / http://190.22.22.40:6060/
</VirtualHost>

Apache proxypass issue with firefox

I've got a wordpress blog running in a docker container, and I'm trying to reverse proxy to it from a virtualhost in the host's apache config. My vhost config looks like this:
<VirtualHost *:80>
ServerName my.vhost.com
ProxyRequests off
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:8084/
ProxyPassReverse / http://127.0.0.1:8084/
</VirtualHost>
When I visit it in chrome, it works fine. When I pull it through curl it looks fine. But when I go to the my.vhost.com in firefox it redirects me to the host ip address (no port).
Does anyone know what's going on here?

Apache host header proxy

I have multiple urls coming into a server. I want to user host headers to redirect the traffic. I am trying to use Apache to redirect these requests to various servers that are inside our firewall. I have gotten part of the solution, but, I seem to be missing something.
For example, http://hostHeader1.mycompany.com should be redirected to a server inside our firewall that handles requests for hostHeader1, and the result should be handed back to the client. http://hostHeader2.mycompany.com should be redirected to a server inside our firewall that handles requests for hostHeader2. Etc.
Right now, I have the following, but, it redirects all traffic to http://hostHeader1Handler/:
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://hostHeader1Handler/
ProxyPassReverse / http://hostHeader1Handler/
ServerName hostHeader1.mycompany.com
</VirtualHost>
Any help appreciated.
Scott
This is probably your first or your only virtual host. Just add another virtual host before. Then this should be the new default.
NameVirtualHost *:*
<VirtualHost *:*>
ServerName your.default.domain.de
DocumentRoot /var/www/pathToHTML
</VirtualHost>
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://hostHeader1Handler/
ProxyPassReverse / http://hostHeader1Handler/
ServerName hostHeader1.mycompany.com
</VirtualHost>