0

I set up a small Digital Ocean droplet a while ago to host my side-project, and while doing it made sure all http:// requests redirect to https:// (using Lets Encrypt certificates). I'm using nginx as the web server. However, I now need to make some changes and cannot remember how I configured nginx to redirect to https every time. I've uninstalled nginx (sudo apt-get purge nginx), which removed all the files.

I have now re-installed nginx, but nothing loads; even just going to http://DROPLET_IP redirects to https://DROPLET_IP but then fails to load (not even hanging, just a quick no-response from my browser). However, I've tried to set up a couple of my nginx virtual hosts but these redirect as well, and do the same as above.

All the config is set to the default, including nginx.conf and sites-available/default (symlinked to sites-enabled/default).

tl;dr: nginx was previously configured to somehow redirect every request to https://, but I now need to disable this but can't figure out how I originally did it.

Is it possible there is another nginx installation somewhere, screwing things up? Or some files hanging around from the previous installation? All the files are located in /etc/nginx, and when I purged nginx from the system I made sure to check they had been removed before re-installing.

My Droplet is running Ubuntu 16.04.

Running netstat -lpnI get this output:

$ netstat -lpn
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
tcp6       0      0 :::5432                 :::*                    LISTEN      -
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Path
unix  2      [ ACC ]     STREAM     LISTENING     469737   26068/systemd       /run/user/1000/systemd/private
unix  2      [ ACC ]     SEQPACKET  LISTENING     8980     -                   /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     8591     -                   /run/lvm/lvmetad.socket
unix  2      [ ACC ]     STREAM     LISTENING     8592     -                   /run/systemd/journal/stdout
unix  2      [ ACC ]     STREAM     LISTENING     9078     -                   /run/lvm/lvmpolld.socket
unix  2      [ ACC ]     STREAM     LISTENING     12629    -                   /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     12631    -                   /run/snapd.socket
unix  2      [ ACC ]     STREAM     LISTENING     12632    -                   /run/snapd-snap.socket
unix  2      [ ACC ]     STREAM     LISTENING     12633    -                   /run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     12636    -                   /run/uuidd/request
unix  2      [ ACC ]     STREAM     LISTENING     15788    -                   /var/run/postgresql/.s.PGSQL.5432
unix  2      [ ACC ]     STREAM     LISTENING     12630    -                   /var/lib/lxd/unix.socket
unix  2      [ ACC ]     STREAM     LISTENING     12717    -                   @ISCSIADM_ABSTRACT_NAMESPACE
unix  2      [ ACC ]     STREAM     LISTENING     8586     -                   /run/systemd/private

My /etc/hosts file is below:

# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 DROPLET_NAME.localdomain DROPLET_NAME
127.0.0.1 localhost
127.0.0.1 subdomain1.domain.com
127.0.0.1 subdomain2.domain.com
127.0.0.1 subdomain3.domain.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Tom Oakley
  • 113
  • 4
  • For future reference, adding `-tu` to `netstat` will only just give you TCP/UDP sockets (filter out the UNIX ones) and running as root will give you the process names :) – Ginnungagap Jun 17 '17 at 22:18

1 Answers1

0

This is happening in your web-browser, probably because of previously enabled HSTS setting for your web-site. You need to address your browser's manuals to determine how to forget HSTS setting. F.e. in firefox you can do this by clearing history for that website: https://support.mozilla.org/en-US/questions/919498

Or you may just use another browser, which you never used to visit that web-site instead.

IMHO, enabling HTTPS and sticking to it would be the best solution, though...

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
Anubioz
  • 3,597
  • 17
  • 23
  • thanks - keeping HTTPS enabled is my goal but I also need to figure out why nginx doesn't seem be to loading at all. Will look at some options for HTST though, thank you. – Tom Oakley Jun 17 '17 at 16:20