Skip to content

Instantly share code, notes, and snippets.

@diecrf
Last active August 29, 2015 13:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save diecrf/9089447 to your computer and use it in GitHub Desktop.
### If a bot requests an escaped URL then rewrite the request to SEO4Ajax location
if ($args ~ _escaped_fragment_) {
rewrite ^(.*)$ /seo4ajax$1 last;
}
### SEO4ajax location to handle proxyfication to SEO4Ajax API
location /seo4ajax/ {
rewrite ^/seo4ajax/(.*) /seo4ajax_key/$1 break;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host api.seo4ajax.com;
proxy_pass http://api.seo4ajax.com;
}
location / {
try_files $uri /index.html;
}
location / {
try_files $uri @seo4ajax;
}
location @seo4ajax {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host api.seo4ajax.com;
set $seo4ajax 0;
### If a bot requests an escaped URL then rewrite the request to SEO4Ajax location
if ($args ~ _escaped_fragment_) {
set $seo4ajax 1;
}
### SEO4ajax location to handle proxyfication to SEO4Ajax API
if ($seo4ajax = 1) {
rewrite ^(.*)$ /seo4ajax_key$1 break;
proxy_pass https://api.seo4ajax.com;
}
if ($seo4ajax = 0) {
rewrite .* /index.html break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment