Getting the URLs right when proxying to apache and mongrel
marc
gmane at auxbuss.com
Sun Sep 2 21:21:03 MSD 2007
Igor Sysoev said...
> On Sun, Sep 02, 2007 at 03:32:25PM +0100, marc wrote:
>
> > Hi,
> >
> > I'm testing nginx by putting it in front of an existing Apache server,
> > and also using it to serve rails via mongrel.
> >
> > This works okay, mostly, but for a couple of things:
> >
> > 1. When I proxy to Apache (on port 81) the URLs are written showing the
> > port, e.g.
> >
> > http://mote:81/Main/Software
> >
> > I'd like not not to see the port number, if possible,
> >
> > I tried using
> >
> > upstream apache {
> > server mote:81;
> > }
> >
> > and
> >
> > location / {
> > proxy_pass http://apache;
>
> proxy_redirect http://mote:81/ /;
>
> > }
Thanks for the assist.
This results in 404s and, in the case of *.php files, the browser trying
to download the file.
> >
> > but that resulted in URLs of the form: http://apache/...
> >
> > 2. The url required to access the rails app fails without the trailing
> > slash. So,
> >
> > http://mote/rails/
> >
> > works, but the following doesn't
> >
> > http://mote/rails
>
> In your configuration, proxied request is "GET HTTP/1.0".
> What request should go to mongrel for /rails ?
I don't know. Whatever it gets in the current script is fine -
notwithstanding the problem mentioned before.
>
> > I'd like the latter to work, if possible,
> >
> > I've added my conf file below for reference.
>
> > user www-data;
> > worker_processes 1;
> >
> > error_log /var/log/nginx/error.log;
> > pid /var/run/nginx.pid;
> >
> > events {
> > worker_connections 1024;
> > }
> >
> > http {
> > include /etc/nginx/mime.types;
> > default_type application/octet-stream;
> > access_log /var/log/nginx/access.log;
> > sendfile on;
> > keepalive_timeout 65;
> > tcp_nodelay on;
> > gzip on;
> > gzip_min_length 1100;
> > gzip_buffers 4 8k;
> > gzip_types text/plain;
> >
> > upstream mongrel {
> > server 127.0.0.1:8000;
> > server 127.0.0.1:8001;
> > }
> >
> > server {
> > listen 80;
> > server_name mote;
> >
> > access_log /var/log/nginx/localhost.access.log;
> > root /var/www;
> > index index.html index.htm;
> >
> > location / {
> > proxy_pass http://mote:81;
>
> proxy_redirect http://mote:8000/ /;
> proxy_redirect http://mote:8001/ /;
I'm not clear what this would do. I don't want to redirect to mongrel
here, but to Apache - to serve php and python.
Should I be using the redirect mentioned higher up here?
>
> > }
> >
> > location ^~ /rails {
> >
> > proxy_set_header X-Real-IP $remote_addr;
> > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> > proxy_set_header Host $http_host;
> > proxy_redirect false;
> >
> > if (!-f $request_filename) {
> > root /home/marc/rails/mrctest/public;
> > rewrite ^/rails(.*) $1;
> > proxy_pass http://mongrel;
> > break;
> > }
> > }
> >
> > error_page 500 502 503 504 /50x.html;
> > location = /50x.html {
> > root /var/www/nginx-default;
> > }
> > }
> > }
--
Cheers,
Marc
More information about the nginx
mailing list