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

Redirect http to https. #695

Closed
ericrini opened this issue Oct 7, 2015 · 3 comments
Closed

Redirect http to https. #695

ericrini opened this issue Oct 7, 2015 · 3 comments

Comments

@ericrini
Copy link

ericrini commented Oct 7, 2015

Is it possible to add a vhost that expresses this idea using this module?

server {
       listen         80;
       server_name    my.domain.com;
       return         301 https://$server_name$request_uri;
}
@danielburrell
Copy link

I think there's a rewrite_to_https option

@chadothompson
Copy link
Contributor

Yup - if you use rewrite_to_https as such:

  nginx::resource::ghost{'my.domain.com':
    www_root => '/opt/html/',
    rewrite_to_https => true,
   ssl_cert => '...'
  << INSERT VALID SSL SETTINGS >>

  }

(Whatever your root might be) you end up with the following block (or the starts of server blocks):

server {
  listen *:80;
  server_name           my.domain.com;

  if ($ssl_protocol = "") {
       return 301 https://$host$request_uri;
  }
  index  index.html index.htm index.php;

and a second server block:

server {
  listen       *:443 ssl;
  server_name  myhost.com;

  ssl on;

... the module uses the "if ssl protocol" block rather than the direct return.

@3flex
Copy link
Contributor

3flex commented Nov 5, 2015

@ericrini if this addresses your issue please consider closing this, thanks!

@3flex 3flex closed this as completed Feb 8, 2016
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

4 participants