Apache httpd.conf - route request to different port - apache

I have a CentOs 7.1 with Apache httpd running on port 9000.
So if i type in my browser: http://192.168.56.101:9000/ I see the Apache Testing 123 Page.
I also have a GitLab Server running on port 8888, but this port is closed by the firewall.
I want that Apache redirects traffic to http://192.168.56.101:9000/gitlab internally to the GitLab server.
I have done this in my Apache config file /etc/httpd/conf/httpd.conf:
<VirtualHost *:9000>
ProxyPass /gitlab http://192.168.56.101:8888/users/sign_in
ProxyPassReverse /gitlab http://192.168.56.101:8888/users/sign_in
</VirtualHost>
When users browse to http://192.168.56.101:9000/gitlab the login page appears (css seems broken though), but when logging in this appears:
Not Found
The requested URL /users/sign_in was not found on this server.
Is this something that is configurable with Apache and if so how?
Do I need to use some sort of Url-Rewriting, if yes which and how to get started?

All the links in gitlab will presume you are pointing at the original server.
So you need to look at mod_proxy_html to also replace these links in the HTML:
https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html

Related

how to configure on Apache proxy (SSL conection) to Tomcat

I am new in Apache's world, and I need to connect a server (Ubuntu system ) located in my DMZ area to a Tomcat server (Windows server System) in my network. So I wrote on my Ubuntu Apache /etc/apache2/sites-available/default-ssl:
<VirtualHost *:443>
<Location /example>
ProxyPass http://tomcatIP:8080/example/
ProxyPassReverse https://mydomain/example/
</Location>
</VirtualHost>
I restart my Apache and on the browser doesnt display anything, however if i choose source code I can see all the php, javascript, html code.
I checked the log from Apache and there are a lot logs like this:
AH00128: File does not exits: /var/html/...
I checked my firewall and everything is correct. I don`t know why my apache doesn't search on Tomcat server. Do I need more code? on apache.conf?
Many thanks for the help
You need to configure AJP Connector on Web-Server and on Tomcat Application Server.
https://tomcat.apache.org/tomcat-4.0-doc/config/ajp.html
Afer read documentation, I checked the Tomcat configuration and I watched that it wasn't the "tipical" Tomcat, it completly customized for Servicedesk software, and after many tries and fails I couldn't do anything, finally the costumer service told me that is impossible an Apache connection. ¬¬
Thanks anyway!!

How to enable Apache SSL Reverse Proxy on HTTP application

I've been having problems attempting to implement a reverse SSL proxy on Apache for an HTTP application on Ubuntu 14.04. As a baseline, the application works fine when I access it via port 8000 in the browser normally. For all intents and purposes, let's say the IP of my app is 192.141.56.11 (I do not have a domain name yet). The application runs with HTTP Basic Auth, I don't know if it's relevant. Basically I'm fishing for some glaring error here and would be grateful if you could help me out. Here is a log of my process:
I created my SSL cert and key and put them in the following locations:
/etc/apache/ssl/apache.crt (I performed chmod 644 here)
/etc/apache/ssl/apache.key (I performed chmod 400 here)
I then installed:
apt-get install apache2
a2enmod proxy
a2enmod ssl
a2enmod proxy_http
I then disabled the default config with:
a2dissite 000-default
I created the file "/etc/apache2/sites-available/redirect.conf"
I then created the file "/etc/apache2/sites-available/redirect.conf" and copied the text below:
<VirtualHost *:80>
Redirect "/" "https://192.141.56.11"
</VirtualHost>
After, I created the file "/etc/apache2/sites-available/reverse_proxy.conf" and copied below:
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache/ssl/apache.crt
SSLCertificateKeyFile /etc/apache/ssl/apache.key
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
and did:
service apache2 restart
I now attempt to access the UI of the application on another machine in the Chrome browser. When trying:
https://192.141.56.11
I get a general SSL connection error.
However, trying
http://192.141.56.11:8000
gives me the application, as if none of my config changed anything. However,
192.141.56.11:80
gives me an "Index Of" page with an html folder that says "Apache/2.4.7 (Ubuntu) Server at 192.141.56.11 Port 80"
192.141.56.11:443
gives me the same result except with "Apache/2.4.7 (Ubuntu) Server at 192.141.56.11 Port 443"
I've tried all manners of configurations but can't get what I want -- any ideas here?
EDIT: I tried https[:]//192.141.56.11 and got a more specific SSL error:
received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)
EDIT2: After running apache, I get this warning;
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
I suppose this is fine as I am using an IP and not a domain name.
EDIT3: It turns out I needed to do:
a2ensite reverse_proxy.conf.
Now https[:]//192.141.56.11 works but defaults to an apache page. working on this.
EDIT4: I had to do
a2dissite default-ssl.conf
Now It actually redirects to the app on https[:]//192.141.56.11!! But I can still access the app via port 8000, which is bad {still working on}
EDIT5: IN the end, I couldn't figure out how to block access to the original app via port 8000 on Apache. Instead, I just implemented iptables on the server so that it can only be accessed via HTTPS. This is probably not the correct method. but all I could think of.

Apache fresh installation ssl

I've installed Apache on CentOS and have not enabled SSL, and yet I get the following error.
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please. Hint:
https://192.168.1.50/ Apache/2.2.15 (CentOS) Server at 192.168.1.50
Port 443
The page I was testing it is a simple html page.
I did not make many changes to the fleshly installed Apache. The only things I edited are IPTABLES config file to allow LAN access on port 80 and the httpd.conf file to change document root.
I've installed Apache before(on Fedora), but didn't have this problem.
Thank you.
I managed to find the problem. I found a sll.conf file that contains all of the SSL configuration lines. The SSL was enabled by default, its weird. It is located in /etc/httpd/conf.d/ and a simple
<VirtualHost _default_:443>
SSLEngine off
</VirtualHost>
did the trick.

Doing a proxy pass server on apache to tomcat+liferay

I have three sites hosted on liferay, and they use only one portal instance, therefore only one tomcat host.
I configured the virtual host properties on liferay, so when I type www.domain1.com, it goes to the right site.
However, when I type domain1.com, without the www prefix, it goes to the default liferay site.
One solution that I got was to do a proxy and rewrite server with apache 2, with mod_proxy_http and mod_rewrite modules.
The sites like domain1.com are rewritten to www.domain1.com, and I do a proxy pass like this:
ProxyPass / http://localhost:8085
ProxyPassReverse / http://localhost:8085
The tomcat server listens to the 8085 port, and apache listens to 8080.
But when the proxy pass goes on, I get a 403 - forbidden status.
I don't have a site hosted on apache, and I think that's why I got this status.
But I don't want to have any sites on apache, because the sites are on tomcat.
Is there a way to do this proxy setup without hosting a site on apache? Or maybe hosting a
"dummy" site, just to get the proxypass to work.
Specs:
Liferay 6.1
, Tomcat 7.0.27
, Apache 2.x
, Ubuntu Server 12.04
Best Regards!
Guilherme
try it without "/"
ProxyPass http://localhost:8085
ProxyPassReverse http://localhost:8085
or, maybe, you can do it with tomcat configuration: http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Host_Name_Aliases

Connect apache and coldfusion 10 using mod_proxy_ajp

I'm trying to setup my local development environment and I'm only missing one piece of the puzzle.
I was able to successfully install the following on my Mac OSX 10.7.5 x86_x64
XAMPP - http://www.apachefriends.org/en/xampp-macosx.html
ColdFusion 10 - Developer Edition
Both are running fine. I was able to pull up localhost (Apache) and localhost:8500 (ColdFusion) - my ajp connector port is 8012
Now I want to be able to pass the request to my ColdFusion from Apache using mod_proxy_ajp.
I created an index.cfm file on the wwwroot/cf directory of ColdFusion, enabled the NameVirtualHost and created a VirtualHost directive in Apache that looks like this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
<Location "/cf">
Allow from all
ProxyPass ajp://localhost:8012/
</Location>
</VirtualHost>
After restarting everything, I get a 503 error.
Any help or pointers is much appreciated.
Thanks!
check your CF logs:
{cf_root}/cfusion/logs/coldfusion-error.log
You probably have something like this in the log:
org.apache.coyote.ajp.AjpProcessor getRealPathFromServer
SEVERE: Error in getRealPathFromConn
java.io.IOException: Socket read failed
So mod_proxy_ajp is passing the request to Tomcat, but Tomcat can't read it.
Have you tried configuring with mod_jk instead?
http://helpx.adobe.com/coldfusion/kb/coldfusion10-apache-manual-connector-configuration.html
Might not be the way you want to configure it, but it should get you up and running.