NGINX – HTTPS & HTTP (When Needed)

Screen Shot 2016-06-21 at 6.42.13 PM

After HTTPS was turned on to deal with one issue it, of course, kicked off another unforeseen one. All of the screencast.com content failed to laod. You can see that happening above. It’s never a bad idea to take a look at the console using Chrome’s developer tools when weird stuff happens to a site.

Since I couldn’t change anything on the screencast.com side of things, I needed to be able to load this particular site as HTTP rather than HTTPS.

I tried a variety of paths based on various Stack Overflow suggestions. I’m not entirely sure I didn’t fix it in various other ways but this one seems to work. I will note that NGINX is a bit like regit and htaccess in that as I get deeper and deeper I begin to suspect it is actually witchcraft.

So, to give full directions. I’m SSH’ing into the server via Terminal.

I’m navigating to where my NGINX file lives.

cd /etc/nginx/sites-enabled

I’m opening the file in Nano.

sudo nano wordpress

The 443 server block was already in place. I added the location element within that block. It waits for requests on 443 and should stop the http://rampages.us/psy323 site from being pushed up to https.

location /psy323/ {
                return 301 http://$server_name$request_uri;
        }

I also added a second server block listening at the regular port 80 that does nothing with the psy323 address.

server {
        listen 80;
        server_name rampages.us;
        location /psy323/ {}
}

Next up is writing out the changes and reloading NGINX.

ctrl+O
ctrl+X to exit
sudo service nginx reload

Comments on this post

  1. Tom Woodward said on June 21, 2016 at 7:42 pm

    I don’t know how much of this is true anymore. It’s complicated by some stuff Chrome does. I think I’ll force https on some stuff tomorrow and see what’s what.

Leave a Reply

Trackbacks and Pingbacks on this post

No trackbacks.

TrackBack URL