Welcome! Log In Create A New Profile


nginx proxy apache rewrite: no 301

Posted by shart 
nginx proxy apache rewrite: no 301
March 10, 2011 06:09PM
I lost my apache re-write when I put nginx in front as a proxy.

I use nginx 0.8.54 to proxy apache 2.2.16 on Ubuntu 8.04 32-bit.

My apache rewrite is configured in the vhosts.conf file:

RewriteEngine On
RewriteCond %{SERVER_ADDR} !^127\.0\.0\.1
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteRule ^/(.*)$ http://www.mysite.com/$1 [R=permanent,NE,L]

When I proxy through Nginx: mysite.com no longer re-writes to www.mysite.com.

My nginx.conf

#Nginx to proxy apache2

user shwa;
worker_processes 12;
error_log /usr/nginx/default/logs/error.log debug;
pid /usr/nginx/default/pid/nginx.pid;

events {
worker_connections 4096;

http {
include /usr/nginx/default/conf/mime.types;
include /usr/nginx/default/conf/conf.d/*.conf;
include /usr/nginx/default/sites-enabled/*;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status "$request" "$http_referer" "$http_user_agent"'
access_log /usr/nginx/default/logs/access.log;
server_names_hash_bucket_size 64;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_comp_level 5;
gzip_http_version 1.0;
gzip_min_length 0;
gzip_types text/plain text/css image/x-icon application/x-javascript;

My nginxVhosts.conf

server {
listen 6222;
server_name www-6222;
access_log /usr/nginx/default/logs/6222access.log;
error_log /usr/nginx/default/logs/6222error.log debug;
location / {

My proxy.conf


proxy_redirect http://www.mysite.com/ http://mysite.com;
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 10m;
client_body_buffer_size 128k;
client_header_buffer_size 64k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 1m;
proxy_buffers 32 64k;
proxy_busy_buffers_size 1m;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 77
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready