diff --git a/confs/nginx-wikipedia.conf b/confs/nginx-wikipedia.conf index e6934ce..0fc43b5 100644 --- a/confs/nginx-wikipedia.conf +++ b/confs/nginx-wikipedia.conf @@ -8,29 +8,84 @@ http { client_body_buffer_size 10M; client_max_body_size 10M; log_format main "$remote_addr - $remote_user [$time_local] - \"$request\" \"$status\" $body_bytes_sent \"$http_referer\" - \"$http_user_agent\" \"$http_x_forwarded_for\""; + \"$request\" \"$status\" $body_bytes_sent \"$http_referer\" + \"$http_user_agent\" \"$http_x_forwarded_for\""; server { listen 6666; - # process the request without using Host header - server_name _; - sub_filter_once off; sub_filter_types text/html text/css application/x-javascript text/xml; - sub_filter "https://en.wikipedia.org" "op-en"; + + # !!! the replacing order is important + # !!! longest string to shortest, first relative paths, then absolute + sub_filter "/static/" "/op-en-static/"; + sub_filter "/w/" "/op-en-w/"; + + # replace everything in responses with + sub_filter "https://en.wiktionary.org" "/op-en-wiktionary"; + sub_filter "https://en.wikisource.org" "/op-en-source"; + sub_filter "https://en.wikivoyage.org" "/op-en-voyage"; + sub_filter "https://en.wikiquote.org" "/op-en-quote"; + sub_filter "https://en.wikibooks.org" "/op-en-books"; + sub_filter "https://en.wikipedia.org" "/op-en-wiki"; + sub_filter "//en.wikipedia.org" "/op-en-wiki"; + sub_filter "en.wikipedia.org" "/op-en-wiki"; access_log /home/onionproxy/nginx_access.log main; + # international landing page location / { + # Disable compressed requests to allow NGINX sub_filter + proxy_set_header Accept-Encoding ""; proxy_set_header Host www.wikipedia.org; proxy_pass https://wikipedia.org; } - location /op-en { + # BEGIN: EN wiki + proxy_redirect $scheme://$host:$server_port http://$host:80; + proxy_redirect https://en.wikipedia.org/wiki http://$host:80/op-en-wiki; + proxy_redirect https://en.wikipedia.org/w http://$host:80/op-en-w; + location /op-en-wiki { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikipedia.org; + proxy_pass https://en.wikipedia.org/wiki; + } + location /op-en-w { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikipedia.org; + proxy_pass https://en.wikipedia.org/w; + } + location /op-en-static { + proxy_set_header Accept-Encoding ""; proxy_set_header Host en.wikipedia.org; - proxy_pass https://en.wikipedia.org; + proxy_pass https://en.wikipedia.org/static; + } + location /op-en-wiktionary { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikipedia.org; + proxy_pass https://en.wiktionary.org; + } + location /op-en-source { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikipedia.org; + proxy_pass https://en.wikisource.org; + } + location /op-en-quote { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikiquote.org; + proxy_pass https://en.wikiquote.org; + } + location /op-en-voyage { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikivoyage.org; + proxy_pass https://en.wikivoyage.org; + } + location /op-en-books { + proxy_set_header Accept-Encoding ""; + proxy_set_header Host en.wikibooks.org; + proxy_pass https://en.wikibooks.org; } + # END: EN wiki } }