We have hosted some xml files in a S3 bucket on Amazon AWS. The web server is powered by Nginx. For a particular URL matching '/super-shots.xml' , Nginx must proxy pass through S3 location which is : http://mybucket.s3.amazonaws.com/depth0/depth1/depth2/sitemap.xml
What I want is this (Nginx Config):
location ~* /super-shots.xml {
proxy_pass http://mybucket.s3.amazonaws.com/depth0/depth1/depth2/sitemap.xml;
}
Result is an error:
nginx: [emerg] "proxy_pass" cannot have URI part in location given by
regular expression, or inside named location, or inside "if"
statement, or inside "limit_except" block
If I do not do a regular expression match (~*|~), then there is no syntax errors, but the page returns 404. Note that the file does not exists on system path.
I have tried looking around for solution, but most of deal with path as a match. How do I work around this?
For now, I have done a path based proxy-pass which works (given below). But, I want it with the URL match.
#Nginx Config:
location /super-shots {
proxy_pass http://mybucket.s3.amazonaws.com/depth0/depth1/depth2/sitemap.xml;
}
# On file system : Empty directory
mkdir $docroot/depth0/depth1/depth2/
nginx -s reload
Update 1:
Based on Alexey Ten's comment.
Sample of the Nginx Configuration can be found here
Best Answer
Have you tried simple?
You don't need anything on local file system.
Your problem is that request
/super-shot.xml
matcheslocation ~* \.(js|ico|...xml...
. Using=
suffix we tell nginx that this exact request should be processed here and it must not look for other possible matching locations.