Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm having some trouble with my nginx server configuration. So far its pretty simple for a site. I'm trying to redirect from non www to www. I have nginx running on a vm on my windows server 2008 ( i'm running a puppet master to configure vps's, so i just pointed all traffic to go through it)

I'm trying to direct any non www to www for both http:// and https:// here is my config non http works but https doesn't

server {
  server_name example;
  return 301 $scheme://$host$request_uri;

server {
  listen      80;
  listen      443 ssl;
  server_name  wwwexample;

  ssl                  on;
  ssl_certificate      /etc/nginx/ssl/;
  ssl_certificate_key  /etc/nginx/key/;

  ssl_session_timeout  5m;

  ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers  ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
  ssl_prefer_server_ciphers   on;

  access_log  /var/log/nginx/example.access.log  main;
  error_log  /var/log/nginx/example.error.log;
  root   /var/www/html;
  index  index.html index.htm;

  ## send request back to iis ##
  location / {
    proxy_pass  http://192.168.x.x;
    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    #proxy_redirect http:// https://;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
share|improve this question
Related:… – Deer Hunter Jul 7 '13 at 20:52
I don't think the two are entirely related, but thanks for the help. It pointed me to look back at a configuration. I realized something. I'm hosting my personal site from home so its on a dyndns url, Which i can't put in the dns host entry. so i have a permanent forward to www there ( not set for https) I'll have to figure that one out now. I think the configuration would have worked otherwise. Thanks ! and sorry for wasting anyones time, I never post because i always find my answers here or answer them as i type them up for someone else's input. Thanks again! – blankstar85 Jul 7 '13 at 23:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.