Skip to content

Instantly share code, notes, and snippets.

@Barbery
Last active March 28, 2016 05:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Barbery/927ae66c70c581586800 to your computer and use it in GitHub Desktop.
Save Barbery/927ae66c70c581586800 to your computer and use it in GitHub Desktop.
reverse proxy gist
server {
listen 80;
server_name gist.stutostu.com;
access_log off;
resolver 8.8.8.8;
location / {
proxy_pass https://gist.github.com$request_uri;
proxy_connect_timeout 6s;
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent $http_user_agent;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
@Barbery
Copy link
Author

Barbery commented Jan 10, 2015

需要在http{}block下添加 resolver 8.8.8.8;

@tvvocold
Copy link

server {
    listen 80;
    server_name gist.stutostu.com;
    access_log off;

    location / {
        proxy_pass https://gist.github.com$request_uri;
        resolver 8.8.8.8;
        proxy_connect_timeout 6s;
        proxy_set_header Accept-Encoding "";
        proxy_set_header User-Agent $http_user_agent;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

这样?

@Barbery
Copy link
Author

Barbery commented Feb 1, 2015

resolver可以添加到: http, server, location 中,你们可以根据需求自行添加

Copy link

ghost commented Sep 7, 2015

# server, gist reverse proxy
server {
    listen  80;
    server_name gist.liamhuang.me;
    access_log  off;
    resolver    8.8.8.8;

    location / {
        proxy_pass  https://gist.github.com;
        proxy_cache_valid   200 302 1h;
        proxy_cache_valid   404 1m;
        proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
        proxy_redirect  https://gist.github.com/ /;
        proxy_set_header    Accept-Encoding "";
        proxy_set_header    Accept-Language "zh-CN";
        proxy_set_header    User-Agent $http_user_agent;
        sub_filter  https://gist-assets.github.com/ http://gist.liamhuang.me;
        sub_filter  https://gist.github.com/ http://gist.liamhuang.me;
        sub_filter_once off;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment