Nginx as Apache proxy for static content
Genko Penev
genkopenev at gmail.com
Fri Nov 20 16:47:29 MSK 2009
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/
More information about the nginx
mailing list