Learn about Centmin Mod LEMP Stack today
Register Now

SSL redirect from non www to www and http to https

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Chuman, Aug 5, 2015.

  1. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    I am not able to properly redirect from non www to www and from http to https

    there are two conf files domain.conf and domain.ssl.conf
    I have uncommented the lines to redirect from non www to www
    It works but I am not able to redirect the site from http to https://
    Please help
    I want both www and without www version redirected to https://
    Conf
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name mydomain.com;
                return 301 $scheme://www.mydomain.com$request_uri;
            }
    
    server {
                server_name www.mydomain.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      root /home/nginx/domains/mydomain.com/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      }
    
      location / {
    
    SSL Conf
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    # For SPDY SSL Setup
    # read http://centminmod.com/nginx_configure_https_ssl_spdy.html
    
    # redirect from www to non-www  forced SSL
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    # server {
    #   server_name mydomain.com www.mydomain.com;
    #   return 302 https://$server_name$request_uri;
    #}
    
    server {
      listen 443 ssl spdy;
      server_name mydomain.com www.mydomain.com;
    
      ## redirect non www to www
      if ($host = 'mydomain.com' ) {
      rewrite  ^/(.*)$  https://www.mydomain.com/$1  permanent;
      }
    
      ssl_dhparam /usr/local/nginx/conf/ssl/mydomain.com/dhparam.pem;
      ssl_certificate      /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.crt;
      ssl_certificate_key  /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.key;
      include /usr/local/nginx/conf/ssl_include.conf;
    

     
    Last edited: Aug 5, 2015
  2. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
    change in non-ssl config file

    Code:
    server {
                listen   80;
                server_name mydomain.com;
                return 301 $scheme://www.mydomain.com$request_uri;
            }
    
    to
    Code:
    server {
                listen   80;
                server_name www.mydomain.com;
                return 301 https://www.mydomain.com$request_uri;
            }
    
    and add
    Code:
       ##  redirect https non-www to https www
          if ($host = 'mydomain.com' ) {
             return 302 https://www.mydomain.com$request_uri;
          }
    so that non-https www.mydomain.com access redirects to https based https://www.mydomain.com and so that any access via non-www mydomain.com redirects to https based https://www.mydomain.com

    in ssl config file replace
    Code:
    server {
      listen 443 ssl spdy;
      server_name mydomain.com www.mydomain.com;
    
      ## redirect non www to www
      if ($host = 'mydomain.com' ) {
      rewrite  ^/(.*)$  https://www.mydomain.com/$1  permanent;
      }
    
    with the following - replace 302 temp redirect with 301 permanent redirect after you confirm it works.

    Code:
    server {
      listen 443 ssl spdy;
      server_name mydomain.com www.mydomain.com;
    
       ##  redirect https non-www to https www
          if ($host = 'mydomain.com' ) {
             return 302 https://www.mydomain.com$request_uri;
          }
    
    restart nginx

    Do all tests in incognito/private browser session so 301 permanent redirects are NOT cached in browser
     
    Last edited: Aug 5, 2015
    • Informative Informative x 1
    • Useful Useful x 1
  3. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Sir

    Thank you very much for your wonderful clarification and help, it worked like a charm,
     
    • Like Like x 1
  4. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
    excellent glad to hear it worked :)
     
  5. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
  6. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
    Centmin Mod 1.2.3-eva2000.08 stable has centmin.sh menu option 22 for auto setup of wordpress + wp super cache at Beta Branch - Preview: Wordpress + WP Super Cache installer - centmin.sh option 22 | Centmin Mod Community

    So you can delete the wordpress vhost setup you made via centmin.sh menu option 2 using steps outlined at Nginx Vhost & NSD DNS Setup - CentminMod.com LEMP Nginx web stack for CentOS and then use centmin.sh menu option 22. You might want to backup the old wordpress vhost conf file you created via centmin.sh menu option 2 as you can compare it to the auto generated ones from centmin.sh menu option 22 and learn what changes where made so you know what to do manually if you ever need to :)

    However, Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)

    you mean via centmin.sh menu option 22 ?

    what version of Centmin Mod you using 1.2.3-eva2000.07 stable or .08 stable ? centmin.sh menu 22 is only in 08 stable. So need to update first Upgrade Centmin Mod - CentminMod.com LEMP Nginx web stack for CentOS
     
  7. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
  8. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
  9. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Thank you very much for the great replies
    Yes I was using 22 option for the WordPress nginx Vhost +wp super cache
    I am using Centmin Mod 1.2.3-eva2000.08

    Thank you I will follow your guidelines
     
  10. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    I have done a fresh installation of CentmindMod and I still have problems redirection the site from http to https and from non www to www https and from https non www to https www

    When I browse the site in http:// it gives me the Apache page, only when I browse in https:// I get the site

    Plese help !
     
  11. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
  12. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Sir yes nginx..
    I disabled the http configuration
    Code:
    mv /usr/local/nginx/conf/conf.d/newdomain.com.conf /usr/local/nginx/conf/conf.d/newdomain.com.conf-disabled
    
    Then
    or to (for redirecting http://newdomain.com and http://www.newdomain.com to https://www.newdomain.com)

    Code:
    server {
        server_name mydomain.com www.mydomain.com;
        return 302 https://www.$server_name$request_uri;
     }
    
    restarted nginx
    got the following warnings

    Code:
    service nginx restart
    nginx: [warn] conflicting server name "mydomain.com" on 0.0.0.0:80, ignored
    nginx: [warn] conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
    nginx: [warn] conflicting server name "mydomain.com" on 0.0.0.0:80, ignored
    nginx: [warn] conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
    nginx: [warn] conflicting server name "mydomain.com" on 0.0.0.0:80, ignored
    nginx: [warn] conflicting server name "www.mydomain.com" on 0.0.0.0:80, ignored
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
    So how can I resolve this.
     
  13. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
    backup /usr/local/nginx/conf/conf.d/newdomain.com.conf-disabled locally and delete the /usr/local/nginx/conf/conf.d/newdomain.com.conf-disabled and restart nginx server does that work ?
     
  14. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Sir deleted the disabled conf file from /usr/local/nginx/conf/conf.d
    and restarted nginx but didn't help !

    The page still loads the Nginx welcome page
     
  15. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
    also post contents of your config files for
    • /usr/local/nginx/conf/conf.d/mydomain.com.conf-disabled
    • /usr/local/nginx/conf/conf.d/mydomain.com.conf
    • /usr/local/nginx/conf/conf.d/mydomain.com.ssl.conf
    • /usr/local/nginx/conf/conf.d/virtual.conf
    wrapped in CODE tags How to use forum BBCODE code tags | Centmin Mod Community

    and ensure mydomain.com DNS is working properly and has A record pointing to main server's IP address
     
    Last edited: Sep 13, 2015
  16. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Sir,
    here are the conf files you wanted

    • /usr/local/nginx/conf/conf.d/mydomain.com.conf-disabled
      Code:
      # Centmin Mod Getting Started Guide
      # must read http://centminmod.com/getstarted.html
      
      # redirect from non-www to www 
      # uncomment, save file and restart Nginx to enable
      # if unsure use return 302 before using return 301
      server {
                  listen   80;
                  server_name www.mydomain.com;
                  #return 301 $scheme://www.mydomain.com$request_uri;
      	    return 301 https://www.mydomain.com$request_uri;
            	    ##  redirect https non-www to https www
            if ($host = 'mydomain.com' ) {
               return 302 https://www.mydomain.com$request_uri;
            		}
      	}
      
      server {
        server_name mydomain.com www.mydomain.com;
      # ngx_pagespeed & ngx_pagespeed handler
      #include /usr/local/nginx/conf/pagespeed.conf;
      #include /usr/local/nginx/conf/pagespeedhandler.conf;
      #include /usr/local/nginx/conf/pagespeedstatslog.conf;
      
        # limit_conn limit_per_ip 16;
        # ssi  on;
      
        access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=256k flush=60m;
        error_log /home/nginx/domains/mydomain.com/log/error.log;
      
        root /home/nginx/domains/mydomain.com/public;
      
        # prevent access to ./directories and files
        location ~ (?:^|/)\. {
         deny all;
        }
      
      include /usr/local/nginx/conf/wpsupercache_mydomain.com.conf;  
      
        location / {
      
        # Enables directory listings when index file not found
        #autoindex  on;
      
        # for wordpress super cache plugin
        try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
      
        # Wordpress Permalinks
        #try_files $uri $uri/ /index.php?q=$uri&$args;  
      
        }
      
      location ~* /(wp-login\.php) {
          limit_req zone=xwplogin burst=1 nodelay;
          #limit_conn xwpconlimit 30;
          auth_basic "Private";
          auth_basic_user_file /home/nginx/domains/mydomain.com/htpasswd_wplogin;    
          include /usr/local/nginx/conf/php-wpsc.conf;
      }
      
      location ~* /(xmlrpc\.php) {
          limit_req zone=xwplogin burst=2 nodelay;
          #limit_conn xwpconlimit 30;
          include /usr/local/nginx/conf/php-wpsc.conf;
      }
      
        include /usr/local/nginx/conf/wpsecure_mydomain.com.conf;
        include /usr/local/nginx/conf/php-wpsc.conf;
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/drop.conf;
        #include /usr/local/nginx/conf/errorpage.conf;
        include /usr/local/nginx/conf/vts_server.conf;
      }
      
    • /usr/local/nginx/conf/conf.d/mydomain.com.ssl.conf
      Code:
      # Centmin Mod Getting Started Guide
      # must read http://centminmod.com/getstarted.html
      # For SPDY SSL Setup
      # read http://centminmod.com/nginx_configure_https_ssl_spdy.html
      
      # redirect from www to non-www  forced SSL
      # uncomment, save file and restart Nginx to enable
      # if unsure use return 302 before using return 301
      # server {
      #   server_name mydomain.com www.mydomain.com;
      #    return 302 https://$server_name$request_uri;
      # }
      server {
          server_name mydomain.com www.mydomain.com;
          return 302 https://www.$server_name$request_uri;
       }
      
      server {
        server_name mydomain.com www.mydomain.com;
      
        ##  redirect https non-www to https www
            if ($host = 'mydomain.com' ) {
               return 302 https://www.mydomain.com$request_uri;
        }
      
        ssl_dhparam /usr/local/nginx/conf/ssl/mydomain.com/dhparam.pem;
        ssl_certificate      /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.crt;
        ssl_certificate_key  /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.key;
        include /usr/local/nginx/conf/ssl_include.conf;
      
        # mozilla recommended
        ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
        ssl_prefer_server_ciphers   on;
        add_header Alternate-Protocol  443:npn-spdy/3;
        #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
        #add_header  X-Content-Type-Options "nosniff";
        #add_header X-Frame-Options DENY;
        spdy_headers_comp 5;
        ssl_buffer_size 1400;
        ssl_session_tickets on;
        
        # enable ocsp stapling
        #resolver 8.8.8.8 8.8.4.4 valid=10m;
        #resolver_timeout 10s;
        #ssl_stapling on;
        #ssl_stapling_verify on;
        #ssl_trusted_certificate /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com-trusted.crt;  
      
      # ngx_pagespeed & ngx_pagespeed handler
      #include /usr/local/nginx/conf/pagespeed.conf;
      #include /usr/local/nginx/conf/pagespeedhandler.conf;
      #include /usr/local/nginx/conf/pagespeedstatslog.conf;
      
        # limit_conn limit_per_ip 16;
        # ssi  on;
      
        access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=256k flush=60m;
        error_log /home/nginx/domains/mydomain.com/log/error.log;
      
        root /home/nginx/domains/mydomain.com/public;
      
        # prevent access to ./directories and files
        location ~ (?:^|/)\. {
         deny all;
        }
      
      include /usr/local/nginx/conf/wpsupercache_mydomain.com.conf;  
      
        location / {
      
        # Enables directory listings when index file not found
        #autoindex  on;
      
        # for wordpress super cache plugin
        try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
      
        # Wordpress Permalinks
        #try_files $uri $uri/ /index.php?q=$uri&$args;  
      
        }
      
      location ~* /(wp-login\.php) {
          limit_req zone=xwplogin burst=1 nodelay;
          #limit_conn xwpconlimit 30;
          auth_basic "Private";
          auth_basic_user_file /home/nginx/domains/mydomain.com/htpasswd_wplogin;    
          include /usr/local/nginx/conf/php-wpsc.conf;
      }
      
      location ~* /(xmlrpc\.php) {
          limit_req zone=xwplogin burst=2 nodelay;
          #limit_conn xwpconlimit 30;
          include /usr/local/nginx/conf/php-wpsc.conf;
      }
      
        include /usr/local/nginx/conf/wpsecure_mydomain.com.conf;
        include /usr/local/nginx/conf/php-wpsc.conf;
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/drop.conf;
        #include /usr/local/nginx/conf/errorpage.conf;
        include /usr/local/nginx/conf/vts_server.conf;
      }
      
    • /usr/local/nginx/conf/conf.d/virtual.conf
      Code:
      server {
      #         listen   80;
                  listen   80 default_server backlog=2048 reuseport;
                  server_name mydomain.com;
                  root   html;
      
              access_log              /var/log/nginx/localhost.access.log     main buffer=256k flush=5m;
              error_log               /var/log/nginx/localhost.error.log      error;
      
      # ngx_pagespeed & ngx_pagespeed handler
      #include /usr/local/nginx/conf/pagespeed.conf;
      #include /usr/local/nginx/conf/pagespeedhandler.conf;
      #include /usr/local/nginx/conf/pagespeedstatslog.conf;
      
      # limit_conn limit_per_ip 16;
      # ssi  on;
      
              location /nginx_status {
              stub_status on;
              access_log   off;
              allow 127.0.0.1;
              #allow youripaddress;
              deny all;
              }
      
                  location / {
      
      # block common exploits, sql injections etc
      #include /usr/local/nginx/conf/block.conf;
      
      # 		Enables directory listings when index file not found
      #		autoindex  on;
      
      #		Shows file listing times as local time
      #		autoindex_localtime on;
      
      #		Enable for vBulletin usage WITHOUT vbSEO installed
      #		try_files		$uri $uri/ /index.php;
                  
                  }
      
              # example nginx-http-concat
              # /csstest/??one.css,two.css
              #location /csstest {
              #concat on;
              #concat_max_files 20;
              #}
      
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/include_opcache.conf;
      include /usr/local/nginx/conf/php.conf;
      #include /usr/local/nginx/conf/phpstatus.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_mainserver.conf;
      
             }
      
     
  17. eva2000

    eva2000 Administrator Staff Member

    30,613
    6,862
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,304
    Local Time:
    8:56 PM
    Nginx 1.13.x
    MariaDB 5.5
    /usr/local/nginx/conf/conf.d/mydomain.com.conf-disabled is incorrectly configured but deleting it should solve that

    /usr/local/nginx/conf/conf.d/mydomain.com.ssl.conf is also incorrectly configured as you removed the ssl spdy listen directive and duplicated listen 80 directives hence warn on restart

    duplicates when no listen directive is set it defaults to listen 80;
    Code:
    server {
        server_name mydomain.com www.mydomain.com;
        return 302 https://www.$server_name$request_uri;
    }
    
    server {
      server_name mydomain.com www.mydomain.com;
    corrected /usr/local/nginx/conf/conf.d/mydomain.com.ssl.conf
    Code:
    server {
        server_name mydomain.com www.mydomain.com;
        return 302 https://www.$server_name$request_uri;
    }
    
    server {
      listen 443 ssl spdy;
      server_name mydomain.com www.mydomain.com;
    
      ##  redirect https non-www to https www
          if ($host = 'mydomain.com' ) {
             return 302 https://www.mydomain.com$request_uri;
      }
    
      ssl_dhparam /usr/local/nginx/conf/ssl/mydomain.com/dhparam.pem;
      ssl_certificate      /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.crt;
      ssl_certificate_key  /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com.key;
      include /usr/local/nginx/conf/ssl_include.conf;
    
      # mozilla recommended
      ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
      ssl_prefer_server_ciphers   on;
      add_header Alternate-Protocol  443:npn-spdy/3;
      #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
      #add_header  X-Content-Type-Options "nosniff";
      #add_header X-Frame-Options DENY;
      spdy_headers_comp 5;
      ssl_buffer_size 1400;
      ssl_session_tickets on;
    
      # enable ocsp stapling
      #resolver 8.8.8.8 8.8.4.4 valid=10m;
      #resolver_timeout 10s;
      #ssl_stapling on;
      #ssl_stapling_verify on;
      #ssl_trusted_certificate /usr/local/nginx/conf/ssl/mydomain.com/mydomain.com-trusted.crt;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/mydomain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      root /home/nginx/domains/mydomain.com/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      }
    
    include /usr/local/nginx/conf/wpsupercache_mydomain.com.conf;
    
      location / {
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      }
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
        auth_basic "Private";
        auth_basic_user_file /home/nginx/domains/mydomain.com/htpasswd_wplogin;
        include /usr/local/nginx/conf/php-wpsc.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwplogin burst=2 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
    }
    
      include /usr/local/nginx/conf/wpsecure_mydomain.com.conf;
      include /usr/local/nginx/conf/php-wpsc.conf;
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    /usr/local/nginx/conf/conf.d/virtual.conf is also incorrectly setup

    as per Getting Started Guide step 1 you need to configure main host nginx vhost properly
    you have in virtual.conf
    Code:
    server_name mydomain.com;
    that is why your mydomain.com access is going to nginx welcome page and not your web site

    change it to
    Code:
    server_name host.mydomain.com;
    and add a valid DNS A record for host.mydomain.com to your server IP

    Gettings Started Step 1 has other instructions including changing or setting system hostname if not set

    you can find your default hostname if it's already set when server was provisioned (at order time set hostname) using command
    Code:
    hostname
    and
    Code:
    uname -n
    that hostname should be the one usually set in /usr/local/nginx/conf/conf.d/virtual.conf for server_name and shouldn't be the same as any site you add via centmin.sh menu option 2

    Getting Started Guide step 18 summary Getting Started Guide - CentminMod.com LEMP Nginx web stack for CentOS
     
    Last edited: Sep 13, 2015
  18. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Thank you very much Sir for your wonderful support and detailed help.. I made the changes accordingly and now it's working properly.
     
    • Like Like x 1
  19. RoldanLT

    RoldanLT Well-Known Member

    3,936
    961
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,312
    Local Time:
    6:56 PM
    1.11
    10.2
    • Like Like x 1
  20. Chuman

    Chuman New Member

    12
    2
    3
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    4:41 PM
    1.9.3
    10.0.20
    Thank you for the suggestion.. I will surely think of it.