SSI goes to backend

In the html for the backend app server is:

Going to directly to http://www.domain.com/ssi/base.html in a browser
shows the file ok

However if it gets loaded as ssi, the request seems to go to the
backend (which says 404) - instead of being served from nginx.

Why is this?

Nginx config:

    location / {
        ssi on;
        proxy_set_header Host $http_host;
        proxy_pass http://backend;
        proxy_redirect off;
    }
    location /ssi {
        alias /var/www/ssi;
    }

On Fri, Sep 04, 2009 at 01:55:50AM +0300, zepolen wrote:

    }

On Fri, Sep 04, 2009 at 02:19:19PM +0300, zepolen wrote:

Thanks, that worked. Why would using the domain not work?

What if for example you want to ssi from a different domain name so
the html is served from http://www.domain.com/ but the ssi uses
www.other.com (which is also hosted on the same nginx instance).

The main technical problem now is that you can not set proxy parameters
in this case and may use default ones only.

2009/9/4 Igor S. [email protected]:

On Fri, Sep 04, 2009 at 01:55:50AM +0300, zepolen wrote:

Going to directly to http://www.domain.com/ssi/base.html in a browser
shows the file ok

However if it gets loaded as ssi, the request seems to go to the
backend (which says 404) - instead of being served from nginx.

Thanks, that worked. Why would using the domain not work?

What if for example you want to ssi from a different domain name so
the html is served from http://www.domain.com/ but the ssi uses
www.other.com (which is also hosted on the same nginx instance).

Hi,

What if for example you want to ssi from a different domain name so
the html is served from http://www.domain.com/ but the ssi uses
www.other.com (which is also hosted on the same nginx instance).

You could set the SSI command to

Then in your config have

location /domain2/ {
internal; # if you don’t set this location to internal then your
web server could be used as a public proxy to that domain
proxy_pass http://domain2.com;

}

This would make a sub-request for http://domain2.com/oth-domain-url.

AFAIK you need to set the domain2 statically in your config file, i.e.
you can’t use a regex in the domain name.

Marcus.

Igor S. wrote:


resvoler 127.0.0.1;

location /p/(\w+) {
proxy_pass http://$1;
}

I tried that, but am getting the following message in the error log:

2009/09/04 17:10:10 [error] 18834#0: *1 zero length URI to proxy,
client: 127.0.0.1, server: localhost, request: “GET /ssi/test.shtml
HTTP/1.1”, subrequest: “/proxy-google/google.com”, host: “localhost”

The locations I’ve tried are:

location ~ /proxy-google/(\w+)
location ~ /proxy-google/(.+)

with proxy_pass http://$1;

and the error message is the same.

I even tried doing

location ~ /proxy-google/(.+) {
set $proxy_url $1;
proxy_pass http://$proxy_url;
}

and that gave the same message.

Doing a statically-defined proxy-pass like above works without the
resolver directive. I don’t have a DNS server running, but I wouldn’t
have thought that I’d need one, would I?

This is true in 0.8.11 and 0.8.13.

Marcus.

On Fri, Sep 04, 2009 at 03:14:42PM +0300, Marcus C. wrote:

Then in your config have
AFAIK you need to set the domain2 statically in your config file, i.e.
you can’t use a regex in the domain name.

No, you may use regex and then resolve a name:

resvoler 127.0.0.1;

location /p/(\w+) {
proxy_pass http://$1;
}

However, here you will lost query string.

On Fri, Sep 04, 2009 at 05:34:21PM +0300, Marcus C. wrote:

proxy_pass http://domain2.com;

HTTP/1.1", subrequest: “/proxy-google/google.com”, host: “localhost”

  • /proxy-google/google.com
  • /proxy-google/google.com/

If I use that setup with the resolver defined as 127.0.0.1, I get
multiple copies of the following error:

2009/09/04 17:56:56 [alert] 22981#0: recv() failed (111: Connection
refused)

Do I need a DNS server running? I tried it with multiple domains, and
the same errors are given.

If I use that setup without the resolver defined, there’s a segmentation
fault :

2009/09/04 18:08:44 [error] 12059#0: *2 no resolver defined to resolve
google.com, client: 127.0.0.1, server: localhost, request: “GET
/ssi/test.shtml HTTP/1.1”, subrequest: “/proxy/google.com/”, host:
“localhost”
2009/09/04 18:08:44 [notice] 12053#0: signal 17 (SIGCHLD) received
2009/09/04 18:08:44 [alert] 12053#0: worker process 12059 exited on
signal 11

That’s on version 0.8.13 with no 3rd-party modules installed.

Marcus.

On Fri, Sep 04, 2009 at 06:17:31PM +0300, Marcus C. wrote:

If I use that setup with the resolver defined as 127.0.0.1, I get
multiple copies of the following error:

2009/09/04 17:56:56 [alert] 22981#0: recv() failed (111: Connection refused)

Do I need a DNS server running? I tried it with multiple domains, and
the same errors are given.

Yes, you need to run DNS server on 127.0.0.1.

Igor S. wrote:

  • /proxy-google/google.com
    the same errors are given.

Yes, you need to run DNS server on 127.0.0.1.

Ok.

This still looks like a minor bug, though. I’ve not really got the time
to dig around and find/correct it, but am happy to test a patch.

Marcus.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs