URL redirection using .htaccess - apache

My website is deployed and running on apache server from enomcentral hosting environment with only limited access so i can't change any configuration setting except htaccess file. Also another application running on tomcat in different domain server with full admin access.
e.g - www.example.com is running on enomcental. and tomcat application running on www.abc.com/xyz.
I want to access tomcat application, running on different domain ,using the url www.example.com/xyz.
so when I enter Url www.example.com/xyz the URL remains same but the content should be comes form www.abc.com/xyz i.e., tomcat server example/
URL redirection changing the browser URL.
I can only change ion .htaccess file.
mod_jk.so configuration not allowed.

What you need is mod_proxy, if enabled,
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
then, this rule will work.
RewriteRule ^xyz$ http://www.abc.com/xyz [P]
P means proxy, docs here.
But if mod_proxy is disabled, then could you make the /xyz point to some cgi(e.g proxy.php), which is under your control, and make the cgi read content from http://www.abc.com/xyz?

Related

Domain Name cannot be changed in Apache on CentOS 7

I have set up a server with a wiki and Wordpress and Nextcloud on a new Domain, let's say it's testing.com. When I was finished, I wanted to change the Domain from testing.com to realdomain.com.
The server is running CentOS 7 with httpd (apache), so I changed the ServerName in /etc/httpd/conf/ to "realdomain.com". Then I changed the VirtualHosts in all the files in /etc/httpd/conf.d.
I added the new Domain to the trusted Domains of the Wordpress, Nextcloud and wiki. I restarted the httpd service and the server itself.
Yet, when I open realdomain.com in browser, it shows me my websites, but it puts testing.com in the address field.
I tried using mod_rewrite to change the URL, but then my webbrowser tells me that the site doesnt redirect correctly and that the redirects never stop.
I tried those rewrite rules in the .conf files and in the .htaccess (not simultaneously)- no success.
I removed all my files in conf.d and created a new DocumentRoot with a simple helloWorld.html - The Url still gets rewritten to testing.com.
Are there any other locations that could have rewrite rules? Did I miss anything?
Thank you so much in advance, this is killing me!

Apache HTTP Server stopped working when using "https://" in xampp localhost

Google chrome update their security. how to enable HTTPS:// in xampp?
1) There is the config file xampp/apache/conf/extra/httpd-ssl.conf which contains all the ssl specific configuration. The files starts with <IfModule ssl_module>, so it only has an effect if the apache has been started with its mod_ssl module. Open the file xampp/apache/conf/httpd.conf in an editor and search for the line
#LoadModule ssl_module modules/mod_ssl.so
remove the hashmark, save the file and re-start the apache.
2) Also if you your document root is not properly configured than it might give you permission denied error. check for DOC ROOT
Check the highlighted text
I found this here. Refer to this for any help.

TeamCity behind an Apache proxy server

I have installed latest TeamCity 9, now I want to access it from the public Internet via HTTPS. So I followed the instructions to setup TeamCity behind an Apache proxy server, as described in the official docs.
Now when I try to access the TeamCity server in the browser I get a 404 page from the Tomcat server. I am not sure what I did wrong, but the issue might be related to the /tc sub folder I have moved the content ROOT into (as described in the docs).
When I connect directly from the server to http://localhost:8111/tc I get exactly the same 404 message.
I feel a bit lost here.
Any ideas where I should look for the error?
PS: When I move the content ROOT back into the original folder, and set the Apache proxy accordingly, then it works fine. So the issue is indeed related to the /tc sub folder.
This is what worked for me
Step 1: I installed teamcity at the port 8080
Step 2: Moved all contents of <teamcity_home>\webapps\ROOT\*.* to <teamcity_home>\webapps\teamcity
Step 3: Created <Apache_Home>\conf\extra\httpd-teamcity.conf with the following contents
ProxyRequests Off
ProxyPass /teamcity http://localhost:8080/teamcity connectiontimeout=240 timeout=1200
ProxyPassReverse /teamcity http://localhost:8080/teamcity
Step 4: Added the following to <Apache_Home>\conf\httpd.conf file
#Include TeamCity Settings
Include conf/extra/httpd-teamcity.conf
and uncommented the following
# Modules to load to redirect teamcity
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Step 5: Accessed Teamcity via http://localhost:8080/teamcityORhttp://localhost/teamcity
Note: you can no longer access teamcity via http://localhost:8080
And update the configuration of your agent to point to the new server location.

Apache webserver rewrite all URL's excluding some

I'm using apache httpd v2.2 server as a frontend proxy for our actual tomcat web server which hosts the Java web application.
I want to forward all urls received by apache webserver other than those having the prefix /product to tomcat.
I've tried the following set up in httpd.conf but it' doesn't seem to work
<VirtualHost *:6111>
ServerName localhost
RewriteEngine on
RewriteRule !^(/product($|/)) http://localhost:1234/$1
Alias /product /opt/productdoc
</VirtualHost>
I tried to follow Redirect site with .htaccess but exclude one folder but was not successful
Basically all http://localhost:6111/product urls should serve from hard drive (using alias)
Any other url should be forwarded to http://localhost:1234/<original-path>
You probably want to use something like mod_jk http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html.
There are a ton of examples and tutorials and it should be pretty simple to setup and install. Now that you know the name of the connection technology, you should probably be able to find more information.
Using modjk also allows you to secure your tomcat server and keep the public off of it.

Rewrite URL - Apache in front and jboss serving content

I have been trying to get this work for the last 2 days since I am relatively new to Apache server. This is what I am trying to do in my local machine.
I have installed Apache Server and it acts as a front gate for all requests and sends them to JBOSS server. This is through AJP method.
I have enabled the mod_rewrite in http.conf and I want to do a simple redirect in my localhost. Below is what I tried..
RewriteEngine on
RewriteRule ^first.html$ second.html
This is not working as the log says it is looking the files in the document root C:\Apacheserver\Apache2\htdocs and i dont have any files in this location as the file comes from JBOSS(For ex: C:/jboss4.0/jboss-4.0.3SP1/server/MyApp/deploy/unisysv2.ear/web-app.war).
How do I make this redirect work under this condition.
Thanks
You should configure "bridge" between Apache an JBoss. Use mod_jk module or mod_proxy for that purpose, which are implementation of ajp communication protocol between Apache and JBoss.