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

One thought on “NGINX – HTTPS & HTTP (When Needed)

Comments are closed.