skip to Main Content

I have a VPS running Ubuntu + Nginx. There’s an old website I’m no longer using, so I followed these steps (based on these instructions, and these to remove the SSL.

  1. cd /etc/nginx/sites-enabled
  2. sudo rm oldwebsite.com
  3. cd ../sites-available
  4. sudo rm oldwebsite.com

Next, I figured I could also delete the relevant files in /var/www/

  1. cd /var/www/
  2. sudo rm -r oldwebsite.com

Now when I try to access www.oldwebsite.com, I still get the same website, just without HTTPS anymore. I’ve checked /etc/nginx/sites-available/default for any remaining references to that website, but as far as I know, I’ve erased all traces of its existence from my server.

Was this the incorrect way to delete an old website?

If it helps, my old website was set up to use a reverse proxy to direct to my Express app. It was set up as a server block according to this guide.

2

Answers


  1. So first of all if you dont want to make it accessable anymore delete the Host A record on your DNS. With this the DNS query will not point to any severs IP address.

    Based on your comment: If its showing the APACHE defaults page your DNS points to an IP address of an webserver running httpd. So let me draft a couple of steps for you how I would do it (as somebody how moved 10K of sites from and to NGINX).

    1. DNS is key

    Check the current DNS Setting for your domain. Do a quick lookup using tools like host or dig.

    $# host nginx.org
    nginx.org has address 52.58.199.22
    

    So great now we know the public IPv4 of our WebServer (we are not talking about LoadBalancers or anything else in between. We asume the webserver is directly conncted to the internet.)

    2. WebServer configuration

    On your server make sure nginx is installed and listening on port 80 for example.

    $# netstat -tulpn | grep "LISTEN"
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      25674/nginx: master
    

    Great. We have NGINX listen on Port 80. Let make sure we can send reuqest.

    $# curl -v http://YOURDOMAIN
    * About to connect() to localhost port 80 (#0)
    *   Trying ::1...
    * Connection refused
    *   Trying 127.0.0.1...
    * Connected to localhost (127.0.0.1) port 80 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.29.0
    > Host: localhost
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Server: nginx/1.19.5
    < Date: Sun, 14 Feb 2021 08:47:56 GMT
    < Content-Type: text/plain
    < Content-Length: 10
    < Connection: keep-alive
    <
    localhost
    * Connection #0 to host localhost left intact
    

    So if you got an response that means your NGINX is up and running, listening on port 80 and there is no firewall (ufw, firewalld, iptables, security-groups…) blocking your from reaching out to the server.

    NOTICE: Make sure your firewall setup is done right. Let me know if you need more information on that depending on your systems architecture.

    NGINX Configuration

    Lets say your website should just print out a String saying "We will be here shortly!"

    Based on your OS the configuration directory for custom nginx files can be different. Check the default /etc/nginx/nginx.conf file and see the include path in the http context. This should be something like: include conf.d/*.conf or sites-enabled/*.conf. Create a conf-file in one of that directories.

    server {
      listen 80;
      server_name YOURDOMAIN.com
      
      location {
        add_hedaer "Content-Type: text/html";
        return 200 "We will be here shortly!n";
      }
    }
    

    With this simple setup you can have a webserver up and running but not showing anyhing special. If you want to create a little html file feel free to do so and use root and index to configure it in your nginx configuration.

    Login or Signup to reply.
  2. After deleting enter command sudo systemctl restart nginx

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search