Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Nginx: Should I choose default or mydomain.conf configuration to serve a single domain in a server?

I am new Nginx. Currently, I configured my domain to be served by Nginx on the default configuration as follows and it is working.

sudo nano /etc/nginx/sites-available/default

Default configuration:

server {
    listen        80;
    server_name   uidcenterkl.my *.uidcenterkl.my;
    location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

However, I learnt that I need to create domain specific directive such as mywebiste.com.conf as follows:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

sudo nano /etc/nginx/sites-available/mywebiste.com.conf

Question:

What should I choose, default or mywesbite.com.conf to serve a single domain? And if I went with mywebsite.com.conf, how to deactivate default configuration so that it does not cause conflict.

>Solution :

You may actually not need to set up domain specific directive to serve a single domain. `default directive should work fine for you.

And if you choose to use mywesbite.com.conf, all you need to do to disable default is to delete it from inside sites-enabled directory

After creating your mywesbite.com.conf feel free to delete the default.conf by running this command from your sites-enabled dirctory:

sudo rm ../sites-enabled/default.conf

Don’t forget to restart your nginx after that command

systemctl restart nginx
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading