Reputation: 13610
Site is almost completely contained in one html file. All other files may be images, css or javascripts and possibly json files too.
server {
listen 80;
server_name git.vosnax.ru;
location / {
try_files $uri "/index.html";
root /home/sybiam/prod/blog;
index index.html;
}
}
This is my current configuration, but this isn't perfect. It will redirect every requests to index.html unless the file exist which is okay.
Now, I'd like to add some persistence to the site. Like saving and loading the jsons from a server with really simple auth, it as to support GET and POST. Which means that I can't use JSONP
.
The question is only on how to configure nginx to forward all requests to let say /api/*
to my pyramid web server and everything else to index.html unless the file exists.
I could probably host the server on a different domain to make things easier but I have no idea how to handle crossdomain requests. CORS
isn't supported on old IE.
EDIT:
Apparently the query args were always available so it's not a problem anymore. My javascript was overriding the pathname at loadtime and removing the window.location.search
.
Upvotes: 2
Views: 3050
Reputation: 10556
the everything else to index.html unless the files exist is the try_files
bit you have in your location /
-block already
to pass just the /api/*
requests to your other server you add the following to your server block (as a sibling of your location /
-block):
location /api/ {
proxy_pass http://address_of_server_your_passing_to;
}
see the documentation if you want more info on how a request is matched when there's multiple location blocks
Upvotes: 3