Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirecting when using https #93

Closed
sandrocsimas opened this issue Jan 4, 2016 · 4 comments
Closed

Redirecting when using https #93

sandrocsimas opened this issue Jan 4, 2016 · 4 comments

Comments

@sandrocsimas
Copy link

When i send a request to https://www.closic.com/pt?_escaped_fragment_= the server is redirecting to "/pt".

prerender-5 2016-01-04T01:51:54.111Z getting http://www.closic.com/pt
closic-web-0 2016-01-04T01:51:54.153Z - debug: GET /pt 200 4606 - 0.740 ms
closic-web-0 2016-01-04T01:51:54.162Z - debug: GET /lib/animate.css/animate.min.css 200 55522 - 0.662 ms
closic-web-0 2016-01-04T01:51:54.201Z - debug: GET /pt?_escaped_fragment_= 301 - - 96.384 ms
prerender-5 2016-01-04T01:51:54.202Z got 301 in 91ms for http://www.closic.com/pt
closic-web-0 2016-01-04T01:51:54.236Z - debug: GET /lib/fontawesome/css/font-awesome.min.css 200 26711 - 2.174 ms
closic-web-0 2016-01-04T01:51:54.266Z - debug: GET /lib/intl-tel-input/build/css/intlTelInput.css 200 18418 - 1.923 ms
closic-web-0 2016-01-04T01:51:54.268Z - debug: GET /css/main.css 200 5220 - 3.645 ms
closic-web-0 2016-01-04T01:51:54.270Z - debug: GET /lib/angular-loading-bar/build/loading-bar.min.css 200 2236 - 5.715 ms
closic-web-0 2016-01-04T01:51:54.277Z - debug: GET /css/responsive.css 200 603 - 2.315 ms
closic-web-0 2016-01-04T01:51:54.279Z - debug: GET /css/paper.min.css 200 142634 - 3.211 ms
closic-web-0 2016-01-04T01:51:54.402Z - debug: GET /pt 200 4606 - 0.727 ms

Why this is happening? The log in closic-web shows that /pt?escaped_fragment= are redirecting but i'm not finding the code that redirects. Can be a prerender-node middleware bug?

When i run locally without https its working fine.
I added www.closic.com in /etc/hosts and configured nginx locally too.
(http://www.closic.com/pt?_escaped_fragment_=)

@sandrocsimas
Copy link
Author

This is my nginx configuration:

server {
  listen      80;
  server_name closic.com;
  return      301 https://www.closic.com$request_uri;
}

server {
  listen      80;
  server_name ~^(?<subdomain>.+)\.closic\.com$;
  return      301 https://$subdomain.closic.com$request_uri;
}

server {
  listen      443 ssl;
  server_name www.closic.com;
  ssl_certificate     /usr/local/nginx/ssl/www.closic.com/server.chained.crt;
  ssl_certificate_key /usr/local/nginx/ssl/www.closic.com/server.key;

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header Host $http_host;
    proxy_pass       http://127.0.0.1:4000;
    proxy_redirect   off;
  }
}

server {
  listen      443 ssl;
  server_name api.closic.com;
  ssl_certificate     /usr/local/nginx/ssl/api.closic.com/server.chained.crt;
  ssl_certificate_key /usr/local/nginx/ssl/api.closic.com/server.key;

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header Host $http_host;
    proxy_pass       http://127.0.0.1:3000;
    proxy_redirect   off;
  }
}

server {
  listen      3101 ssl;
  server_name api.closic.com;
  ssl_certificate     /usr/local/nginx/ssl/api.closic.com/server.chained.crt;
  ssl_certificate_key /usr/local/nginx/ssl/api.closic.com/server.key;

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_set_header Host $http_host;
    proxy_pass       http://127.0.0.1:3102;
    proxy_redirect   off;
  }
}

@sandrocsimas
Copy link
Author

It seems that prerender is requesting the server using http.

prerender-5 2016-01-04T01:51:54.111Z getting http://www.closic.com/pt

Nginx redirects this url to https url.
How to tell prerender to request the https url?

@thoop
Copy link
Contributor

thoop commented Jan 4, 2016

Wherever you are sending the request to Prerender.io, you'll want to set the protocol to https. It sounds like you might be doing SSL termination in front of your server so that's why you're sending Prerender.io a request to an http URL.

@thoop thoop closed this as completed Jan 4, 2016
@sandrocsimas
Copy link
Author

OK @thoop, the problem was the proxy_pass to http://127.0.0.1:4000. I solved changing the node server running on 4000 to use https. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants