nginx and .htaccess are working together, is this possible? - apache

I am encountering an odd situation that appears to be to good to be true. I have a vps set up with nginx installed/activated for a couple of test domains.
From what i have read, the .htaccess files don't work with nginx. But apparently the .htaccess file/directives are working for me under nginx.
I verified this by going to netcraft.com and it shows that the webserver is nginx, ab bench also shows nginx as the webserver. But the .htaccess file still can be read. For example, I can deny/allow access, or redirect using the .htaccess file.
Am I misunderstanding the information? nginx webserver can still read .htaccess files and execute directives?

Yea it's possible but there's a trick, the server has both apache and nginx installed, nginx listens to port 80 and apache listens on any other port, nginx would serve the assets directly ( CSS, JS, HTML, etc ) and pass the PHP or whatever app it is to apache, reduces the load on apache a bit, but consumes a little bit more memory because you have 2 servers running.

Related

Apache 2.4 https Reverse Proxy not working

Trying to reverse proxy with https only. All though the ssl & https works with the chosen domain, it is directing to the apache root not the desired reverse proxy server.
So far Ive got the server to force https when http is used. I rewrite www to non www. Ive had reverse proxy work fine when its just http but https goes to the "it works" root file with a green lock.
Any ideas?
So i solved this issue at the last hour. But where i am confused is i solved this by manipulating the config files and using the defualt text. Not by adding my own virtual hosts and injecting code at the bottom like the old days or blogs would suggest. I added proxy rules into the proxy config file. Added cert paths into the ssl config file and that seemed to take over randomly pasting code into http config as it might be sugested elsewhere on the net.

Will .htaccess files still work if Nginx is running (along with Apache)?

Will .htaccess files still work if Nginx is running (along with Apache), or do I need to disable Nginx for them to work?
Thanks!
.htaccess is an Apache config file. Nginx doesn't use it (file is ignored and treated like any other), and Apache config rules don't apply to Nginx.

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.

How do I redirect from Apache to Tomcat?

I'm working on my first Java site. I'm running Apache Tomcat on port 8080, and Apache HTTPD on port 80. The current URL that I can access the site at is (for example) 123.4.5.6:8080. I want to remove the port number from the URL before I point the domain at the new IP.
At the moment I am only using Apache for phpmyadmin, however I plan on using it for CGI scripts and other stuff once I figure out mod_jk etc... So I don't want to change Tomcat's port to 80 and turn off Apache.
I hope this makes sense.
The correct way to do things is to leave Apache at 80 and Tomcat at 8080 and use a plug in (preferably mod_proxy) to proxy Tomcat from Apache. mod_proxy would only take you 10 minutes to set up.
This how-to is very simple to follow.
The usual way this is done, as you already mentioned, is to use mod_jk from Apache HTTPD to forward that content that you want to be processed by Tomcat.
There is a Quick HowTo at tomcat.apache.org. You need to do the following:
Copy mod_jk.so into the appropriate modules directory for Apache HTTPD.
Create a configuration file workers.properties
In Apache HTTPD's httpd.conf, add a section to configure mod_jk.
Ensure that Tomcat is configured to accept the mod_jk protocol, which is usually on port 8009.
The lines in httpd.conf with JkMount:
JkMount /examples/* worker1
tell Apache HTTPD which requests are to be forwarded to Tomcat.
Both the helpful answers above are good, but I much prefer mod_proxy over mod_jk. There's no extra installation to do for mod_proxy, unlike mod_jk, and the setup is much easier. mod_jk gives you more control over detailed tuning of Tomcat parameters, but if you just want a simple redirect from Apache to Tomcat, mod_proxy is the way to go.
If you want static content to be served by Apache instead of Tomcat you should use mod_jk : http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html
And what about SSL - if we want Apache to handle HTTPS, because it is faster then java/Tomcat?
you should configure your tomcat using this link. for tomcat 7
http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html