###################
# #
# SU.SG #
# #
###################
# https://mp.weixin.qq.com/s/H3OOqhFRr0YZGorIAlsCjA
# todo
# replace or remove content-security-policy header
###################
# wikipedia-zh begin
wiki.su.sg:8443 {
gzip
cache
tls {
dns cloudflare
}
log / ./su.sg-access.log "{>CF-Connecting-IP} - {combined} - {host}"
root ./public_su_sg
redir 302 {
if {path} not "/robots.txt"
if_op and
if {path} not "/access/from/{>CF-Connecting-IP}"
if_op and
if {path} not "/ip"
if_op and
if {~su-sg-x-access} not "temp-yes"
/ https://su.sg/?ref={hostonly}
}
redir /ip https://wq.apnic.net/static/search.html?query={>CF-Connecting-IP} 302
rewrite {
if {path} is "/access/from/{>CF-Connecting-IP}"
to /getcookie
}
proxy / https://zh.wikipedia.org {
header_upstream X-Real-IP {>CF-Connecting-IP}
header_upstream X-Forwarded-For {>CF-Connecting-IP}
header_upstream X-Forwarded-Proto {scheme}
header_upstream -Referer
header_upstream User-Agent {>User-Agent}
header_upstream Accept-Language zh-CN,zh;q=0.9
header_upstream Accept-Encoding identity
except /robots.txt /getcookie /ip /access/from/
insecure_skip_verify
}
# cookie filter
filter rule {
content_type text/.*
search_pattern (D|d)omain=\.wikipedia.org
replacement "Domain=.wiki.su.sg"
}
filter rule { # featured
content_type text/.*
search_pattern "
"
replacement "Proxied by su.sg"
}
filter rule { # featured
content_type text/.*
search_pattern document.head.appendChild(script);
replacement "script.src = script.src.replace(\"meta.wikimedia.org\", \"meta-wiki.su.sg:8443\");document.head.appendChild(script);"
}
# gist
filter rule {
path .*
search_pattern gist.github.com
replacement gist.su.sg:8443
}
# github
filter rule {
path .*
search_pattern github.com
replacement github.su.sg:8443
}
# google scholar
filter rule {
content_type text/.*
search_pattern http://scholar.google.com
replacement https://scholar.su.sg:8443
}
filter rule {
content_type text/.*
search_pattern scholar.google.com
replacement scholar.su.sg:8443
}
# general
filter rule {
path .*
search_pattern zh\.wikipedia\.org
replacement wiki.su.sg:8443
}
filter rule {
path .*
search_pattern zh\.m\.wikipedia\.org
replacement m-wiki.su.sg:8443
}
filter rule {
path .*
search_pattern upload.wikimedia.org
replacement up-wiki.su.sg:8443
}
filter rule {
path .*
search_pattern meta\.wikimedia\.org
replacement meta-wiki.su.sg:8443
}
filter rule {
path .*
search_pattern en\.wikipedia\.org
replacement en-wiki.su.sg:8443
}
filter rule {
path .*
search_pattern en\.m\.wikipedia\.org
replacement m-en-wiki.su.sg:8443
}
}
m-wiki.su.sg:8443 {
gzip
tls {
dns cloudflare
}
root ./public_su_sg
log / ./su.sg-access.log "{>CF-Connecting-IP} - {combined} - {host}"
redir 302 {
if {path} not "/robots.txt"
if_op and
if {~su-sg-x-access} not "temp-yes"
/ https://su.sg/?ref={hostonly}
}
proxy / https://zh.m.wikipedia.org {
header_upstream X-Real-IP {>CF-Connecting-IP}
header_upstream X-Forwarded-For {>CF-Connecting-IP}
header_upstream X-Forwarded-Proto {scheme}
header_upstream -Referer
header_upstream User-Agent {>User-Agent}
header_upstream Accept-Language zh-CN,zh;q=0.9
header_upstream Accept-Encoding identity
except /robots.txt
insecure_skip_verify
}
# cookie filter
filter rule {
content_type text/.*
search_pattern (D|d)omain=\.wikipedia.org
replacement "Domain=.m-wiki.su.sg"
}
# gist
filter rule {
path .*
search_pattern gist.github.com
replacement gist.su.sg:8443
}
# github
filter rule {
path .*
search_pattern github.com
replacement github.su.sg:8443
}
filter rule { # featured
path .*
search_pattern "