Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Apr 14, 2010 3:17 am 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
Hello,
I just installed nginx as Reverse Proxy for Apache. But since all IP show as 127.0.0.1 I installed mod-rpaf to Apache so it have normal IP in log. And here I found some strange error, on some pages I have strange redirect to local user ip. Et if I go to “site.com/forum” I send me to “localip/forum”. It strange because if I go to “site.com/forum/” it don’t redirect me, and even more it have some extra redirect on pages like “site.com/forums/search.php?do=getnew” it send to “localip/forums/search.php?searchid=70593”.
If I turnoff mod-rpaf, all starts work fine, but if I turn it I again have same problem. Any one know what case that problem here? Apache? Or maybe vBulletin?
I don’t have may “mod_rewrite” for “forums” in my “.htaccess” file.


Top
   
 Post subject:
PostPosted: Wed Apr 14, 2010 3:36 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
What apache rewrite rules do you have? You should consider using nginx to rewrite not apache.


Top
   
 Post subject:
PostPosted: Wed Apr 14, 2010 3:59 am 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
Here what I have now in my .htaccess, I’m not sure that it possible to replace all that with nginx rewrite, as far as I can understand I can fix 1st part (redirect all users to 'www.' prefix), but other are really hard to migrate.
Code:
<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{HTTP_HOST} ^site1\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]
  RewriteCond %{HTTP_HOST} ^site2\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]
  RewriteCond %{HTTP_HOST} ^site4\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]
  RewriteCond %{HTTP_HOST} ^site3\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]
  RewriteCond %{HTTP_HOST} ^www\.site2\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]
  RewriteCond %{HTTP_HOST} ^www\.site3\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]
  RewriteCond %{HTTP_HOST} ^www\.site4\.com$ [NC]
  RewriteRule ^(.*)$ http://www.site1.com/$1 [L,R=301]

### BOOST START ###
  AddDefaultCharset utf-8
  <FilesMatch "(\.html|\.xml|\.json)$">
    <IfModule mod_headers.c>
      Header set Expires "Sun, 19 Nov 1978 05:00:00 GMT"
      Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    </IfModule>
  </FilesMatch>
  <IfModule mod_mime.c>
    AddCharset utf-8 .html
    AddCharset utf-8 .xml
    AddCharset utf-8 .css
    AddCharset utf-8 .js
    AddCharset utf-8 .json
  </IfModule>
  <FilesMatch "(\.html)$">
    ForceType text/html
  </FilesMatch>
  <FilesMatch "(\.xml)$">
    ForceType text/xml
  </FilesMatch>
  <FilesMatch "(\.json|\.js)$">
    ForceType text/javascript
  </FilesMatch>
  <FilesMatch "(\.css)$">
    ForceType text/css
  </FilesMatch>

  # NORMAL - Cached css & js files
  RewriteCond %{DOCUMENT_ROOT}/cache/perm/%{SERVER_NAME}%{REQUEST_URI}_\.css -s
  RewriteRule .* cache/perm/%{SERVER_NAME}%{REQUEST_URI}_\.css [L,QSA,T=text/css]
  RewriteCond %{DOCUMENT_ROOT}/cache/perm/%{SERVER_NAME}%{REQUEST_URI}_\.js -s
  RewriteRule .* cache/perm/%{SERVER_NAME}%{REQUEST_URI}_\.js [L,QSA,T=text/javascript]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add))|(/(comment/reply|edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{HTTP:Pragma} no-cache [OR]
  RewriteCond %{HTTP:Cache-Control} no-cache [OR]
  RewriteCond %{HTTPS} on
  RewriteRule .* - [S=3]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml -s
  RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.xml [L,T=text/xml]
  RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.json -s
  RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.json [L,T=text/javascript]

  ### BOOST END ###

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  RedirectMatch ^/contribut-missing-images$ /forums/showthread.php?t=67
  RedirectMatch ^/user/password$ /forums/login.php?do=lostpw
  RedirectMatch ^/user/(.*)$ /profile.php
  RedirectMatch ^/users/(.*)$ /profile.php
  RedirectMatch ^/messages$ http://www.site1.com/forums/private.php
 
  #
  # Externally redirect direct client requests for "/index.htm" to "/" in
  # canonical domain (This applies to /index pages in any directory)
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.htm\ HTTP/
  RewriteRule ^(([^/]+/)*)index\.htm$ http://www.site1.com/$1 [R=301,L]
  #
  # Externally redirect to remove multiple contiguous slashes at beginning or end of URL
  RewriteCond %{REQUEST_URI} ^//+(.*)$ [OR]
  RewriteCond %{REQUEST_URI} ^(.*/)/+$
  RewriteRule / http://www.site1.com/%1 [R=301,L]
  #
  # Externally redirect to remove multiple contiguous slashes embedded in URL
  RewriteCond %{REQUEST_URI} ^/([^/]+)//+(.*)$
  RewriteRule // http://www.site1.com/%1/%2 [R=301,L]
 
</IfModule>


Top
   
 Post subject:
PostPosted: Wed Apr 14, 2010 12:28 pm 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
Well now im sure that it not mod_rewrite probem. Even if I remove .htaccess from site I still get that strange redirect to local ip. I even not sure is it really redirect, since I can’t found any info about that “redirect” in logs :(


Top
   
 Post subject:
PostPosted: Thu Apr 15, 2010 3:52 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Here's a question...have you cleared your local cache? Maybe your browser is doing it.


Top
   
 Post subject:
PostPosted: Thu Apr 15, 2010 6:29 am 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
I’m sure that it not local problem, even more. Based on my experiments I can say, that problem in communication in some part between “nginx” and “Apache with mod-rpaf”. Looks like some variable start to return user ip as host name and not web site name. Maybe problem in “nginx” proxy configuration. I forgot to add some thing important :(
Here my nginx config:
Code:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;

server {
listen 80;
server_name _;

location / {
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;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
root /usr/share/nginx/html;
index index.html index.htm index.php;                                     
}
      error_page  404              /404.html;

        location = /404.html {
            root   /usr/share/nginx/html;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        # proxy static
    location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
    root /home/www/static/;
    expires           7d; # caching, expire after 7 days   
        }
    }


Top
   
 Post subject:
PostPosted: Thu Apr 15, 2010 1:03 pm 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
Ok. Looks like I found why it redirect there, now only need to understand how to fix this :(
As soon as I enable mod-rpaf it change server_name in all PHP Variable from server name to user ip :(.
So intend of having this without mod-rpaf:
Code:
HTTP_HOST www.site.com
SERVER_SIGNATURE    <address>Apache Server at www.site.com Port 80</address>
SERVER_SOFTWARE    Apache
SERVER_NAME    www.site.com
SERVER_ADDR    127.0.0.1
SERVER_PORT    80
REMOTE_ADDR    127.0.0.1

With mod-rpaf I have this:

Code:
HTTP_HOST x.x.x.x 
SERVER_SIGNATURE    <address>Apache Server at x.x.x.x Port 80</address>
SERVER_NAME    x.x.x.
SERVER_ADDR    127.0.0.1
SERVER_PORT    80
REMOTE_ADDR    x.x.x.x


Where x.x.x.x is user IP.
Anyone have any ideas why this happening.


Top
   
 Post subject:
PostPosted: Thu Apr 15, 2010 4:41 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Sounds like your mod_rpaf is set up wrong make sure you have the following configuration

Code:
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1


I imagine you don't have the sethostname on.


Top
   
 Post subject:
PostPosted: Fri Apr 16, 2010 5:41 am 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
My “rpaf.conf” include this:
Code:
# Path to mod_rpaf-2.0.so, relative to /etc/httpd/
LoadModule rpaf_module modules/mod_rpaf-2.0.so

RPAFenable On
RPAFsethostname On

# Define our reverse proxy IP.  Only substitute client IP in
# when we receive a request from this IP.
RPAFproxy_ips 127.0.0.1

# The header where the real client IP address is stored.
RPAFheader X-Forwarded-For
So it have sethostname, I think maybe problem in mod_rpaf it self, so I will try to remake it on this weekend.


Top
   
 Post subject:
PostPosted: Fri Apr 16, 2010 5:06 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Weird...no clue then since your setup looks identical to mine. Try a remake and pray!


Top
   
 Post subject:
PostPosted: Sat Apr 17, 2010 5:17 am 
Offline
Senior Newbie

Joined: Wed Apr 14, 2010 3:01 am
Posts: 7
Remake rpaf today and all worked fine. Looks like there was some problem when I compile 1st time.


Top
   
 Post subject:
PostPosted: Sat Apr 17, 2010 5:31 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Glad it's fixed :)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group