Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Forked from gaoyifan/google-fonts-proxy
Created November 17, 2017 02:34
Show Gist options
  • Save ryanlid/80124b51cc86e18eacf331ab9c0b0266 to your computer and use it in GitHub Desktop.
Save ryanlid/80124b51cc86e18eacf331ab9c0b0266 to your computer and use it in GitHub Desktop.
google-fonts-proxy
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name fonts.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
#location @redirect {
# rewrite ^/(.*)$ $scheme://fonts.googleapis.com/$1 redirect;
#}
location / {
proxy_pass https://fonts.googleapis.com/;
proxy_set_header Host fonts.googleapis.com;
include conf.d/google-fonts-proxy-common;
}
}
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name ajax.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ $scheme://ajax.googleapis.com/$1 redirect;
}
location / {
proxy_pass https://ajax.googleapis.com/;
proxy_set_header Host ajax.googleapis.com;
include conf.d/google-fonts-proxy-common;
}
}
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name google-themes.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ $scheme://google-themes.lug.ustc.edu.cn/$1 redirect;
}
location / {
proxy_pass https://themes.googleusercontent.com/;
proxy_set_header Host themes.googleusercontent.com;
include conf.d/google-fonts-proxy-common;
}
}
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name fonts-gstatic.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ https://fonts.gstatic.com/$1 redirect;
}
location / {
proxy_pass https://fonts.gstatic.com/;
proxy_set_header Host fonts.gstatic.com;
include conf.d/google-fonts-proxy-common;
}
}
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name openwrt.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ http://downloads.openwrt.org/$1 redirect;
}
location / {
proxy_pass http://downloads.openwrt.org/;
proxy_set_header Host downloads.openwrt.org;
proxy_connect_timeout 3s;
error_page 500 502 504 @redirect;
}
}
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name storage-googleapis.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ https://storage.googleapis.com/$1 redirect;
}
location / {
proxy_pass https://storage.googleapis.com/;
proxy_set_header Host storage.googleapis.com;
# disable gzip response, otherwise subs_filter cannot parse it
proxy_set_header Accept-Encoding "";
subs_filter_types text/plain application/octet-stream;
subs_filter //gerrit.googlesource.com/ //gerrit-googlesource.lug.ustc.edu.cn/;
proxy_connect_timeout 3s;
error_page 500 502 504 @redirect;
}
}
server {
listen 80;
listen 443;
listen [::]:80;
listen [::]:443;
server_name gerrit-googlesource.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ https://gerrit.googlesource.com/$1 redirect;
}
location / {
proxy_pass https://gerrit.googlesource.com/;
proxy_set_header Host gerrit.googlesource.com;
proxy_connect_timeout 3s;
error_page 500 502 504 @redirect;
}
}
upstream gravatar{
#server www.gravatar.com;
server en.gravatar.com;
}
server {
listen 443;
listen [::]:443;
server_name gravatar.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ https://secure.gravatar.com/$1 redirect;
}
location / {
proxy_pass http://gravatar/;
proxy_set_header Host www.gravatar.com;
proxy_connect_timeout 3s;
error_page 500 502 504 @redirect;
}
}
server {
listen 80;
listen [::]:80;
server_name gravatar.lug.ustc.edu.cn;
access_log /var/log/nginx/revproxy_access.log;
error_log /var/log/nginx/revproxy_error.log;
ssl_certificate /etc/nginx/key/lug.ustc.edu.cn.crt;
ssl_certificate_key /etc/nginx/key/lug.ustc.edu.cn.key;
location @redirect {
rewrite ^/(.*)$ http://www.gravatar.com/$1 redirect;
}
location / {
proxy_pass http://gravatar/;
proxy_set_header Host www.gravatar.com;
proxy_connect_timeout 3s;
error_page 500 502 504 @redirect;
}
}
# disable gzip response, otherwise subs_filter cannot parse it
proxy_set_header Accept-Encoding "";
#subs_filter_types text/html text/css text/xml text/javascript;
subs_filter_types text/css text/xml text/javascript;
subs_filter //fonts.googleapis.com/ //fonts.lug.ustc.edu.cn/;
subs_filter //ajax.googleapis.com/ //ajax.lug.ustc.edu.cn/;
subs_filter //themes.googleusercontent.com/ //google-themes.lug.ustc.edu.cn/;
subs_filter //fonts.gstatic.com/ //fonts-gstatic.lug.ustc.edu.cn/;
proxy_connect_timeout 3s;
error_page 500 502 504 @redirect;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment