Application hosting can become messy over time. You may shut down applications, move applications to a new domain, or you need a subdomain for a limited time.
You may need to clean up your nginx configuration here and there to keep your lean setup. Nothing is worse than keeping every nginx config „just in case”.
This tutorial shows you how to remove an nginx configuration from the
nginx Series Overview
- How To Install the Newest Version of Nginx on Ubuntu
- How to Run GitLab with Self-Signed SSL Certificate
- How to Configure Nginx SSL Certifcate Chain
- How to Fix Nginx SSL PEM_read_bio:bad end line
- How to Remove PEM Password From SSL Certificate
- Advanced Configuration
- How to Fix Reponse Status 0 (Worker Process Exited on Signal 11)
- Redirect Only Root URL Path
- Remove an App/Domain from Sites-Enabled
- How to Serve a Static HTML Page (Coming soon)
- Is Running but Not Serving Sites (Coming soon)
Remove an nginx Config from Sites-Enabled
At first, switch to nginx’s
sites-enabled directory. On Ubuntu/Debian, this is typically located in
/etc/nginx. The installation directory may be different on other operating systems:
Print the directory content and list all the files that are currently configured for nginx to route them through to the Internet:
You may remember that a common way to configure the files in
sites-enabled is a symlink in your file system. This symlink maps the nginx configuration file from
sites-enabled. As with any other file on your file system, you can remove it using
sudo rm your-site-config
Afterwards, you may want to check whether nginx has valid configurations and then reload the service:
sudo nginx -t sudo service nginx reload
If you don’t want to keep the domain configuration around in
sites-available, you can also remove it from there. Removing it from
sites-enabled tells nginx to not expose this domain to the Internet anymore.
Enjoy coding & make it rock!