I'm pretty new to Apache HTTP, and sysadmin-ing in general, so i have this question
I have a domain (www.doamin.com) with an Apache listening to port 80,
also I have an Apache Tomcat on the same domain configured to port 8080.
Is there a way to configure a subdomain (i.e, tomcat.domain.com)
so it will redirect into my tomcat specific application,
so user can access applications through app1.domain.com and app2.domain.com (and it will be served by Tomcat)?
I've seen a lot of mentioning to
mod_jk
and
mod_proxy
but all of the post assumed prior knowledge with Apache.
can someone walk me thorugh?
Many thanks, -PK.
mod_jk is outdated. It is recomended to use mod_proxy (mod_proxy_http or mod_proxy_ajp) to connect forward requests to your apache server to the tomcat.
define a virtual host in your apache config
create a proxy directive that forwards your requests to tomcat
Maybe this SO question give you some hints.
You can define two virtual hosts (app1.domain.tld and app2.domain.tld) that have proxy definitions for their designated apps. Example for app1:
<VirtualHost *:80>
ServerName app1.domain.tld
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/app1
ProxyPassReverse / http://localhost:8080/app1
</VirtualHost>
while Magomi was almost right,
Presenting an exact way to do it.
Add your subdomain to the DNS server
integrate *mod_proxy* into httpf.conf :
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
define two virtual hosts as following
NameVirtualHost *:80
<VirtualHost *:80>
ServerName application.domain.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.domain.com:8080/application/
ProxyPassReverse / http://www.domain.com:8080/application/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:\<pathToApache>\www
ServerName www.domain.com
</VirtualHost>
This will direct your site (www.domain.com) to your Apache HTTP server, and redirect all calls to Application to the Tomcat.
Hope this Helps,
-PK
Related
I have 2 domain name, 1 is "project2.servername.net" ,2 is "www.servername.net"
they both point to same project on local.
I want to set "project2.servername.net" to an other project which is already served by nginx on 192.168.0.9 , If I go to http://192.168.0.9:80 on browser, I will see the index page.
In the other hand, I hope the user which is access from "project2.servername.net" can be redirect to 192.168.0.9, not local project.
I tried:
<VirtualHost *:80>
Servername project2.servername.net
ProxyPass / http://192.168.0.9
ProxyPassReverse / https://192.168.0.9
ProxyPreserveHost On
ProxyRequests Off
</VirtualHost>
<VirtualHost *:80>
Servername www.servername.net
</VirtualHost>
But when I go project2.servername.net , I got "Internal Server Error" by apache server.
How can I fix it?
The problem solve by following settings
<VirtualHost *:80>
#ProxyPreserveHost On
ProxyPass "/" "http://192.168.0.9/"
ProxyPassReverse "/" "https://192.168.0.9"
Servername project2.servername.net
</VirtualHost>
<VirtualHost *:80>
Servername www.servername.net
</VirtualHost>
httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
I didn't activate the proxy_http_module module, It's done by activate it.
I have an apache reverse proxy setup from where I am redirecting to a completely different URL. The destination URL is a cloud-hosted service different from the Apache installation location. The redirect is happening properly. But how do I preserve the original URL and mask this new cloud-hosted URL?
This is my apache httpd.conf on Oracle Linux
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off
<VirtualHost *:80>
ProxyPreserveHost On
ServerName xxx.xxx.xx.xx:80
ServerAlias https://sample-url.cloud.com/
Redirect / https://sample-url.cloud.com/
</VirtualHost>
How to achieve this.
I have VPS and currently i am running 5 Spring boot applications on that server along with httpd.
all html for those applications are inside their respective jars. All of them having different domain names. So after hitting the dns name it should automatically go that port application, right now i need to specify the port number explicitly like example.com:9090 i tried virtual host in httpd.conf but its not working.
Listen 9001
<VirtualHost *:9001>
ServerAdmin admin#admin.askcomputers.co.in
DocumentRoot /var/www/html/example2.com
ServerName www.example2.com
</VirtualHost>
I think you should make sure that you have the proper modules installed for httpd:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Then I think you should have 5 VirtualHost sections with reverse proxy setup:
<VirtualHost www.example1.com:80>
ServerAdmin admin#admin.askcomputers.co.in
ServerName www.example1.com
ProxyRequests Off
ProxyPass / http://localhost:9090
ProxyPassReverse / http://localhost:9090
</VirtualHost>
...
<VirtualHost www.example5.com:80>
ServerAdmin admin#admin.askcomputers.co.in
ServerName www.example5.com
ProxyRequests Off
ProxyPass / http://localhost:9094
ProxyPassReverse / http://localhost:9094
</VirtualHost>
Well, I looked everywhere I could, but if some know where I could find a solution, sorry for asking once again the question.
We are looking to implement this solution :
HTTP client -> Apache 2.4 Reverse Proxy -> HTTP Server => Works OK
HTTPS client -> Apache 2.4 Reverse Proxy -> HTTPS Server => Works OK
But, when the HTTPS server replies with a "302" redirection header, the server name in the header is not translated to the client-side known server name. So, the client fail to connect, due to a DNS error.
We can't add the backend server name in the DNS, so we need that solution to work.
Important notice: the same works in HTTP. It means that when the server reply is a "302" redirection header in HTTP, there's no problem. It works even if the target of the redirection is a HTTPS link. So what is not working is redirecting from HTTPS to HTTPS.
The backend webserver is Tomcat.
The problem is: in HTTPS header, the redirection URL is "https://[backendname]/something.html" but we expect it to be "https://[servername]/something.html"
We've checked that we have no error in log file (error level set to "debug").
Here is our virtual site configuration:
<VirtualHost [reverse proxy IP]:443>
SSLEngine on
SSLProxyEngine on
SSLCertificateFile D:/Apache24/ssl/certs/servername.cer
SSLCertificateKeyFile D:/Apache24/ssl/private/servername.key
ServerName [servername]
ProxyPass / https://[backendname]:443/
ProxyPassReverseCookiePath / https://[backendname]:443/
ProxyPassReverse / https://[backendname]:443/
SetOutputFilter proxy-html
ProxyHTMLEnable On
ProxyHTMLURLMap https://[backendname] https://[servername]
ErrorLog D:/Apache24/logs/custom/[servername]_error.log
CustomLog D:/Apache24/logs/custom/[servername]_access.log combined
SetEnv nokeepalive ssl-unclean-shutdown
</VirtualHost>
Problem related Apache activated modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule xml2enc_module modules/mod_xml2enc.so
So, any help to make this work will be greatly appreciated.
Thanks.
Here is the working solution, as suggested by Michael Akerman
disable caching
write new instruction: ProxyPassReverse https://[backend]/
Thanks for your help
I am new to openshift and i am trying to customize apache config.
I want to add virtual host to openshift.conf.
LoadModule perl_module modules/mod_perl.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Listen localhost:8080
<VirtualHost *:8080>
ServerName somehost
ProxyPass / somehost:8000/ keepalive=On
ProxyPassReverse / somehost:8000/
RequestHeader set X-Forwarded-HTTPS "0"
</VirtualHost>
You can not add a virtual host to the apache config. You would have to use the DIY cartridge or build a custom apache cartridge. If you can give more details on what exactly you are trying to accomplish (looks like a reverse proxy of some type), then maybe we can offer a suggestion, also, we do not allow proxies on openshift.