nginx doesn't find the directory but apache does
Posted
by
Jack Spairow
on Server Fault
See other posts from Server Fault
or by Jack Spairow
Published on 2012-05-30T19:47:46Z
Indexed on
2012/05/30
22:43 UTC
Read the original article
Hit count: 232
I use apache as the backend server and nginx on the frontend. Apache listens to port 8080 and nginx to port 80. What I do is have the root point to the public folder foreach virtualhost:
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
ServerName site.com
ServerAlias site.com *.site.com
DocumentRoot /var/www/site.com/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/site.com/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And here's the nginx config:
server {
listen 80;
access_log /var/log/nginx.access.log;
error_log /var/log/nginx.error.log;
root /var/www/site.com/public;
index index.php index.html;
server_name site.com *.site.com;
location / {
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
proxy_cache one;
proxy_cache_use_stale error timeout invalid_header updating;
proxy_cache_key $scheme$host$request_uri;
proxy_cache_valid 200 301 302 20m;
proxy_cache_valid 404 1m;
proxy_cache_valid any 15m;
}
}
location ~ /\.(ht|git) {
deny all;
}
}
The problem is Apache resolves the domain just fine (site.com:8080)
, but nginx shows instead a 502 Bad Gateway (site.com:80)
. I tried looking at the error_log and access_log but I can't find any hint for why can't nginx work.
EDIT: The problem was I wasn't able to include that isolated config for nginx.
© Server Fault or respective owner