Skip to content

Instantly share code, notes, and snippets.

@rktalusani
Created September 26, 2022 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rktalusani/29c88754b3325329fc08e9ad6bd44f8b to your computer and use it in GitHub Desktop.
Save rktalusani/29c88754b3325329fc08e9ad6bd44f8b to your computer and use it in GitHub Desktop.
location /proxy/ {
if ($request_method = OPTIONS ) {
add_header Allow "POST, GET, OPTIONS";
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Allow-Origin "*";
return 200;
}
resolver 8.8.8.8 ipv6=off;
rewrite /proxy/(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^\/?\n]+)(.+) $2 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $1;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://$1;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_ssl_server_name on;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment