Skip to content

Instantly share code, notes, and snippets.

@vencax
Last active May 20, 2020 03:30
Show Gist options
  • Select an option

  • Save vencax/99f453bc50616e90c71aab33002e3db9 to your computer and use it in GitHub Desktop.

Select an option

Save vencax/99f453bc50616e90c71aab33002e3db9 to your computer and use it in GitHub Desktop.
if ($args ~ "_escaped_fragment_=(.+)") {
#rewrite ^([^?])(.+)_escaped_fragment_=(.+) /api/crawler?_escaped_fragment_=$3$2 last;
rewrite ^ /api/crawler/$1;
}
if ($http_user_agent ~* "googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|facebookexternalhit|twitterbot|developers\.google\.com") {
set $test "SPIDER";
}
# Any route that doesn't have a file extension (e.g. /devices)
location / {
if ($test ~ "SPIDER") {
#rewrite ^(.*)$ /api/crawler/?_escaped_fragment_=/$1;
rewrite ^(.*)$ /api/crawler/?url=$scheme://$server_name$request_uri;
}
try_files $uri /index.html;
expires 2h;
}
location /api/paro/ {
proxy_pass http://localhost:30001/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /api/crawler/ {
proxy_pass http://127.0.0.1:55000$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment