2

I want to use NGINx as a reverse proxy server so I can open my GAE (google app engine) web site from china mainland, because there most of google IP's are blocked by the GFW.

DNS: I have those DNS records:-

A     mydomain.com ==> x.x.x.x
CNAME www          ==> ghs.google.com
CNAME *            ==> ghs.google.com

I'm planing to use geo DNS to point to my reverse proxy in case the request is coming from china mainland, currently I'm testing locally by having hosts record points mydomain.com to localhost.

I have nginx 1.1.19 on ubuntu 12.04.

my site configuration file is:-

server {
  #listen       80;
  listen        443 ssl;
  server_name   mydomain.com;

  ssl on;
  ssl_certificate /home/user/Desktop/ssl/mydomain.com.pem;
  ssl_certificate_key /home/user/Desktop/ssl/mydomain.com.key;
  ssl_session_timeout 5m;
  ssl_protocols SSLv3 TLSv1;
  ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
  ssl_prefer_server_ciphers on;

  large_client_header_buffers 4 16k; 

  access_log /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log;

 # keepalive_timeout 70;

  location / {
    proxy_pass       https://mydomain.com/;
    proxy_set_header Host www.mydomain.com;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Real-HOST  $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Proxy-Hostname $scheme://$http_host;

    proxy_redirect off;
    proxy_intercept_errors on;

    #error_page 500 = /error_page.html;
 }

  #location = /error_page.html {
   # root /local_path_to_static_files_root;
  #}
}

When I tried to open https: //mydomain.com:-

I got a number of connection is too low error at the beginning solve it by adding/editing the following to the nginx.conf file:-

events {
        worker_connections 8024;
        # multi_accept on;
}

then I got too many open files error, I solve it by adding/editing the following to the nginx.conf file:-

worker_rlimit_nofile 5000;

Now I'm getting error 504 Gateway Time-out (connection time out):-

Any idea what I'm doing or did wrong ??

UPDATE:

It turned to be infinite redirecting loop because I have mydomain.com ==> 127.0.0.1 in the hosts file and the reverse proxy pass the requests coming to it to mydomain.com so it keeps requesting it self, I removed the URL proxy passing the request to from hosts to avoid loops.

SOLVED

  • To be sure, your nginx server is not in mainland China, correct? – Michael Hampton Sep 13 '13 at 15:10
  • of course it is not in mainland china, requests coming from china will be redirected to nginx server then GAE by a geo dns , rest of the world requests will go to the GAE servers directly. – montss Sep 14 '13 at 22:08
1

It turned to be infinite redirecting loop because I have mydomain.com ==> 127.0.0.1 in the hosts file and the reverse proxy pass the requests coming to it to mydomain.com so it keeps requesting it self, I removed the URL proxy passing the request to from hosts to avoid loops.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.