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

Little help request #733

Closed
GosthMan opened this issue Dec 30, 2015 · 1 comment
Closed

Little help request #733

GosthMan opened this issue Dec 30, 2015 · 1 comment

Comments

@GosthMan
Copy link

Hello,
I'm not sure where i could ask my question so i decide to put it here.
I'm using this module and is working well but i don't know how to set the following nginx optionunder / :
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
Can anyone tell me how i set the exacly in the puppet config so it would look the same in the nginx vhost config
Thank you in advance

@dhoppe
Copy link
Member

dhoppe commented Sep 17, 2016

Hello,

according to the site Pitfalls and Common Mistakes, you should use return 301 ... instead of rewrite ... permanent.

Unfortunately many of the parameters are not documented very well, but if you take a look at manifests/resource/vhost.pp you will find the parameter rewrite_to_https.

For example this code

class { 'nginx': }

nginx::resource::vhost { 'www.puppetlabs.com':
  www_root         => '/var/www/www.puppetlabs.com',
  rewrite_to_https => true,
}

will generate the following config.

server {
  listen *:80;
  server_name           www.puppetlabs.com;

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

  access_log            /var/log/nginx/www.puppetlabs.com.access.log combined;
  error_log             /var/log/nginx/www.puppetlabs.com.error.log;

  location / {
    root      /var/www/www.puppetlabs.com;
    index     index.html index.htm index.php;
  }
}

@dhoppe dhoppe closed this as completed Sep 17, 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

2 participants