Welcome! Log In Create A New Profile

Advanced

Help required with configuration

Ian
February 20, 2015 03:28PM
Hi,

I thought I knew how to configure an Nginx site, but I've come up with a
situation that has defeated me. Ideas needed.

We are attempting to move an old site to a new one. I can't load nginx
(or anything much) on to the old server because the libraries are so
old. For similar reasons we can't move the old site to the new server.
Old site was written with front page - long gone.

So, I thought to copy the old files to the new server, and test if they
exist, and we delete these files as we create the new pages.
So the logic is, if the old file exists, pass the request over to the
old server. If the old file doesn't exist, we serve the new site. First
is a test to see if the file is static. If so, Nginx to serve, if not,
then pass it using fcgi to Flask.

I have the following config (domain names changed)

server {
server_name www.example.com example.com;
listen 80;
# first test if old file exists.
location / {
root /var/www/oldsite/htdocs; # copy of old site
try_files $uri uri/ @newserver;
# don't serve locally, but proxy pass to old website
proxy_pass http://wwx.example:8080/$uri; # old server on
new sub-domain
}
location @newserver { # old file does not exist, serve from new
root /var/www/newsite/htdocs;
# serve static files with nginx
location ~* \.(gif|jpg|jpeg|css|js)$ { # add other static
types here
try_files $uri =404;
}
location / { # anything NOT static (.htm) is passed to flask
include uwsgi_params;
uwsgi_pass unix:/tmp/uwsgi.sock;
}
}
}

However nginx complains that I can't put location inside location
@newerver.

So how can the site be configured?

Thanks

Ian

--
Ian Hobson
Mid Auchentiber, Auchentiber, Kilwinning, North Ayrshire KA13 7RR
Tel: 0203 287 1392
Preparing eBooks for Kindle and ePub formats to give the best reader experience.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Help required with configuration

Ian February 20, 2015 03:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 221
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready