Hello all,
I think I must be missing something basic here, but I've been looking through the docs and whatever the problem is I can't seem to find it. Suppose I have siteA and siteB, both running on the same server (right now I just have them running on different ports, but I don't think using hostnames would affect the problem I'm seeing).
Both sites support php via fastcgi with a block like this (and cgi.fix_pathinfo is set to 0, per the 'pitfalls' document):
```
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
```
I want requests for siteA/test/... to go to siteB/..., so siteA's config has a line like this:
```
location /test {
proxy_pass http://localhost:82/;
}
```
I tried an alias instead of a proxy_pass in a similar situation, but had the same problem, specifically...
Everything works fine for non-php files, so a request for siteA/test/foo.hml goes to siteB/foo.html as expected, but if I try to access siteA/test/foo.php, fastcgi tries to load `/siteA-root/test/foo.php` instead of `/siteB-root/foo.php`, resulting in an error.
It doesn't seem to matter in what order I put the `location` blocks, siteA's fastcgi always handles the requested url before it can be redirected.
If anyone out there can offer me a hint, I'd really appreciate it! I look forward to smacking my forehead and going "of COURSE!" ;)
Full configs of each site follow:
# SiteA
```
server {
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /www/nginx/portal;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /test {
proxy_pass http://localhost:82/;
}
}
```
#SiteB
```
server {
listen 82 default_server;
listen [::]:82 default_server ipv6only=on;
root /www/nginx/testsite;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
```
I think I must be missing something basic here, but I've been looking through the docs and whatever the problem is I can't seem to find it. Suppose I have siteA and siteB, both running on the same server (right now I just have them running on different ports, but I don't think using hostnames would affect the problem I'm seeing).
Both sites support php via fastcgi with a block like this (and cgi.fix_pathinfo is set to 0, per the 'pitfalls' document):
```
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
```
I want requests for siteA/test/... to go to siteB/..., so siteA's config has a line like this:
```
location /test {
proxy_pass http://localhost:82/;
}
```
I tried an alias instead of a proxy_pass in a similar situation, but had the same problem, specifically...
Everything works fine for non-php files, so a request for siteA/test/foo.hml goes to siteB/foo.html as expected, but if I try to access siteA/test/foo.php, fastcgi tries to load `/siteA-root/test/foo.php` instead of `/siteB-root/foo.php`, resulting in an error.
It doesn't seem to matter in what order I put the `location` blocks, siteA's fastcgi always handles the requested url before it can be redirected.
If anyone out there can offer me a hint, I'd really appreciate it! I look forward to smacking my forehead and going "of COURSE!" ;)
Full configs of each site follow:
# SiteA
```
server {
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /www/nginx/portal;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /test {
proxy_pass http://localhost:82/;
}
}
```
#SiteB
```
server {
listen 82 default_server;
listen [::]:82 default_server ipv6only=on;
root /www/nginx/testsite;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
```