Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Help with Nginx reverse proxy
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Help with Nginx reverse proxy

Hi, all

Since wikipedia is inaccessible from my country, I am wondering if it is possible to reverse proxy it for private use. However, I am bumping into a 500 internal server error.

I am using

w.domain.tld for zh.wikipedia.org

m.w.domain.tld for zh.m.wikipedia.org

up.w.domain.tld for upload.wikimedia.org

Here is my nginx config

    server {
listen 80;
    server_name w.domain.tld ;
    return 301 https://$host$request_uri;
    }
     server {
server_name w.domain.tld;
listen 443;
    ............. #my ssl config
    location / {
proxy_pass https://zh.wikipedia.org;
    proxy_cookie_domain zh.wikipedia.org w.domain.tld;
    proxy_redirect https://zh.wikipedia.org/ /;
    proxy_redirect https://zh.m.wikipedia.org/ https://m.w.domain.tld/;
    proxy_set_header X-Real_IP $remote_addr;
    proxy_set_header User-Agent $http_user_agent;
    proxy_set_header Accept-Encoding ''; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host "zh.wikipedia.org";
proxy_set_header Referer "https://zh.wikipedia.org$request_uri";
    subs_filter_types text/css text/xml text/javascript;
subs_filter zh.wikipedia.org w.domain.tld;
    subs_filter upload.wikimedia.org up.w.domain.tld;
    subs_filter zh.m.wikipedia.org m.w.domain.tld;
sub_filter_once off; 
    }

The config of server block for other two domains corresponding to zh.m.wikipedia.org and upload.wikimedia.org are pretty similar.
No matter what it always shows a 500 error(while nothing appeared in error.log),at the same time ,another similar copy of the config works fine with google.
(I have been tring to sort it out for serveral days and still no clue)

Running nginx 1.2.1 with nginx_substitutions_filter module (which replace my domain instead of wikipedia's domain on any files )

Any thoughts or ideas really appreciated

Kindly

Comments

  • Let me know if you find some solution for it

    Few days back , i asked similar question for youtube
    https://www.lowendtalk.com/discussion/comment/1885217

  • exception0x876exception0x876 Member, Host Rep, LIR

    Though reverse proxying is more convenient, since you can transparently use it on all your devices, it can break if the website structure changes etc.

    I would recommend you to setup SSH tunnel with SOCKS proxy to some VPS. Then you can have one browser for a regular use, and another browser for restricted websites using your SOCKS proxy.

    Thanked by 1thatix
  • Is it possible to forward all https links/connections/requests into http on nginx? I have a chat script that stop working when on https maybe because there are links/content in the script on http so they are blocked when accessing on http and chat stop loading.

  • @exception0x876 said:
    Though reverse proxying is more convenient, since you can transparently use it on all your devices, it can break if the website structure changes etc.

    That's exactly why I want to set this up, under particular circumstances, it would be very inconvenient to use a forward proxy(i.e. someone else's computer or a computer at school)

    The strange thing is that a similar configuration works for Google.

    Still have no idea on this

  • thatixthatix Member
    edited October 2016

    Alright guys, I have finally fixed this sh*t.

    proxy_cookie_domain should be wikipedia.org instead of zh.wikipedia.org otherwise you will get a 500 error.

    Once cookie domain is corrected , a wikipedia mirror site is up :)

    Works pretty fine on a 128MB box thanks to @tragic

    And please consider this project @hammad

    Thanked by 1tragic
Sign In or Register to comment.