Nginx config and wesite path

I installed nginx on vps with ubuntu 24.04

I then apt install nginx 1.27

Then I went to /etc/nginx/sites-available and created “mysite”. I then ln -s site-available and site-enabled as I learnt to do. The site works when the url was mysite IP addr …BUT… it points to the default file and not my “mysite”.

I have no clue where anything is!!! And the nginx.org or the new docs.nginx.org documentation is rather poor in this regard. I understand the ideas presented in it - unless I am mistaken the approach is to surpass the sites-available/enabled approach and move to a nginx.conf to do the switching from default to “mysite” . An example would help as to where the nginx.conf is - (thew doc states that it is found typically one of /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx locations.

Can anyone assist here?

4 Likes

It sounds like the default.conf is still being loaded and without a DNS name, it will accept traffic. If you remove the default.conf from sites-enabled and reload nginx, it should fix the issue. Another option would be to define a server_name for your site and try to reach it with that instead of an IP.

The default.conf usually has the ‘default_server’ parameter set in the listen directive, which will make that the config used for any requests directly to the server IP or if there is not a match for a server_name in any other part of the config.

2 Likes

Hi Damian, (same as my kid’s spelling - great!)
Since the post, I experimented with the config and made progress. Perhaps a slight enhancement to docs is required as there seems to be a change on approach from before…
Once I hacked the /etc/nginx/nginx.conf file the it seemed to work. So then, I ran the certbot and it straightened the files out and it was reliable! I examnied the files and then it became clear as to what to do - A way of learning I suppose!
nevertheless, I proceeded to destroy the VPS and rebuilt based on what was learnt and it sings along now!!!
Now, that I get the concept it is easy - I suggest additional “graphical conceptual diagrams” to convey the pattern as other hopefully do not struggle.
I DO appreciate all that the team does to the benefit of folks like me and others :clap:- Thanks for the response - I thought I was never gonna get this.
PROBLEM SOLVED! :grinning:

2 Likes

Hi @dev4openid! Would you please share the link on docs.nginx.com that you were working from/looking for additional examples on?

Thanks!

1 Like

https://nginx.org/en/docs/

Examples, where where e.g the design changed from say 1.24 to 1.25 and then again from 1.25 to 1.26. I seems (and I could be wrong here (and I can accept that)) there was a design change as to where the configs are set. As a learner - there seems more confusion.
It is ok to change design but allowance for design change impact examples may help.
This will allow folks like me to adapt to the change and have a path to upgrade.
I want to really communicate that this is not a run in with the dev team at all as I support opensource as much as I can. I understand that maybe there is a capacity problem or such (and when is it never the case).
I am stating that newbies may need more help than experienced folks, and docs (ref model) may help - especially like me you are on your own with noone to ask :wink:

A simple example:
In the docs it states as below - (however the doc does not tell you where the file is or it’s name. If you are experienced you already know but if yo not well … I am building everything from scratch and depend on the docs basically and I cannot follow.

Sample Configuration File with Multiple Contexts

The following configuration illustrates the use of contexts.

user nobody; # a directive in the 'main' context

events {
    # configuration of connection processing
}

http {
    # Configuration specific to HTTP and affecting all virtual servers

    server {
        # configuration of HTTP virtual server 1
        location /one {
1 Like

Thanks very much! This type of feedback is incredibly valuable to the docs team. It helps us understand where the gaps are and informs where we should be focusing to make sure we’re helping our users get their jobs done. :slight_smile:

I’ve filed a ticket for this in our docs repo, feel free to follow along there: Clarify and update web server configuration examples in the admin guide · Issue #175 · nginx/documentation · GitHub