Welcome! Log In Create A New Profile

Advanced

Nginx as Apache proxy for static content

November 20, 2009 08:52AM
Hello,

I installed Nginx. Set up as a server for static content and a dynamic
content to be redirected to a Apache server behind. Everything works fine,
server load decreased. I began to serving three times more requests. Glad
that everything worked, but the beam. Rewrite rules don't work.
Here is my configuration of Nginx in /etc/nginx/conf.d/virtual.conf:


#virtual hosts start
#start - _default_
server
{
listen 80;
server_name _default_ alias._default_;

location ~* (/|.php|.phtm|.phtml)$
{
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 128m;

proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
}
location /
{
root /var/www;
}
}
#end - _default_

#start - secretsexpartner.com
server
{
listen 80;
server_name secretsexpartner.com www.secretsexpartner.com
alias.secretsexpartner.com;

location ~* (/|.php|.phtm|.phtml)$
{
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


client_max_body_size 128m;

proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
}

location /
{
root /var//www;
}
}
#end - secretsexpartner.com
#virtual hosts end

I use following .htaccess file on apache root directory:

RewriteEngine on
Options +FollowSymlinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ navigation.php

RewriteRule .* - [E=HTTP_X_REQUESTED_WITH:%{HTTP:X-Requested-With}]


And when try to access web pages that use this rules, nginx tell me Page
not found 404. How to implement this .htaccess to work and with Nginx
frontend.

Thanks in advance!
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Subject Author Posted

Nginx as Apache proxy for static content

Abadon November 20, 2009 08:52AM

Re: Nginx as Apache proxy for static content

Sean Allen November 21, 2009 05:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 202
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready