Help needed with configuration

Hi,

I have the following configuration. Why are a missing .html file, and
the requests for favicon.ico (also missing), all result in a “bad
gateway” error.? The error log shows that the request is passed to
uwsgi, which is aborting 502.

I would have expected the last two configurations to be taken resulting
in a 404.

server {
listen 80;
listen [::]:80 ipv6only=on;
server_name www.mydomain.com mydomain.com, wwp.mydomain.com
localhost;
# localhost so it can be read locally for testing

 access_log /var/log/nginx/gmt.access.log;
 error_log /var/log/nginx/gmt.error.log;
 index index.htm;
 # three way split -> .htm .php and static
 # serve old *.htm, send missing to new
 location ~ \.htm$ {
     root /var/www/mydomain.com/oldhtdocs;
     try_files $uri $uri/ @newflask;
 }
 # for new site, pass .htm to flask
 location @newflask {
     # recieves *.htm where old file is missing
     root /var/www/mydomain.com/htdocs;
     include                     uwsgi_params;
     try_files $uri =404;
     fastcgi_split_path_info ^(.+\.htm)(/.+)$;
     uwsgi_pass                  uwsgicluster;
     uwsgi_param UWSGI_CHDIR     /var/www/mydomain.com/flask;
     uwsgi_param UWSGI_PYHOME /var/www/mydomain.com/flask/venv;
     uwsgi_param UWSGI_MODULE    gmt;
     uwsgi_param UWSGI_CALLABLE  app;
     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_set_header X-Forwarded-Host $server_name;
}
# Pass php files to php via fcgi
location ~ .php$ {
root /var/www/mydomain.com/oldhtdocs;
try_files $uri @newphp;
fastcgi_split_path_info ^(.+.php)(/.+)$;
# NOTE: Must have “cgi.fix_pathinfo = 0;” in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# pass .php to new root or 404
location @newphp {
root /var/www/mydomain.com/htdocs;
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# serve old static files with nginx
location / {
root /var/www/mydomain.com/oldhtdocs;
index index.htm;
try_files $uri $uri/ @newstatic;
}
# serve static new files with nginx
location @newstatic {
root /var/www/mydomain.com/htdocs;
# serve if present, else 404
try_files $uri $uri/ =404;
}
}

By way of explanation, we are migrating from oldhtdocs to a new site,
but having to replace pages in groups. This way I hope we can leave all
the junk behind.

Ubuntu 14:04, with standard versions of all software. Nginx is 1.4.6

Thanks for your ideas,

Ian

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