Learn about Centmin Mod LEMP Stack today
Register Now

SSL Issues with Force www

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by denellum, May 11, 2016.

  1. denellum

    denellum Member

    88
    22
    8
    May 11, 2016
    Dallas
    Ratings:
    +32
    Local Time:
    7:06 AM
    1.13.8
    10.1.29
    Having issues with forcing https://www to a domain. Been beating my head against the desk for the past couple of days to no avail. Do you guys see anything wrong? At this point i feel it's simple and just need a fresh set of eyes. (staring at the same code all day)

    The domain is Anomaly - The Front Page

    Here is the anomaly.ws.conf:


    Here is the anomaly.ws.ssl.conf :


     
  2. eva2000

    eva2000 Administrator Staff Member

    54,868
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    10:06 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Posted at centminmod.com/nginx_domain_dns_setup.html#httpsredirect

    key to testing is using 302 temp redirect first in a private incognito browser session otherwise the problems you can experience may end up being due to browser caching or 301 permanent redirects unless you clear browser cache and reboot local computer(s) and even then some web browsers don't let go of 301 permanent redirect browser cache that willingly :)

    You have it wrong way round those configs are telling to redirect non-www to www
    just change in http port 80 non-ssl vhost conf file

    from
    Code (Text):
    server_name anomaly.ws;
    return 302 $scheme://www.anomaly.ws$request_uri;

    to
    Code (Text):
    server_name anomaly.ws www.anomaly.ws;
    return 302 https://anomaly.ws$request_uri;

    and in https port 443 ssl vhost conf change to
    Code (Text):
    server {
    listen 443 ssl http2;
    server_name anomaly.ws;
     
  3. denellum

    denellum Member

    88
    22
    8
    May 11, 2016
    Dallas
    Ratings:
    +32
    Local Time:
    7:06 AM
    1.13.8
    10.1.29
    First off thank you for the reply!

    But i feel i worded my issue wrong... i want it to force https and www. So i want the following :
    Code:
    http://Anomaly.ws
    www.anomaly.ws
    
    All to redirect to :
    Code:
    Https://www.anomaly.ws
    
     
    Last edited: May 11, 2016
  4. denellum

    denellum Member

    88
    22
    8
    May 11, 2016
    Dallas
    Ratings:
    +32
    Local Time:
    7:06 AM
    1.13.8
    10.1.29
    All resolved, read through that documentation! Solved my issue completely when i disabled the non ssl.conf.

    Thank you for the help eva!!!!
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,868
    12,239
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,810
    Local Time:
    10:06 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+