Open nginx server on the browser with my domain name

Hello, I just have a general question regarding Nginx, and in particular my nginx.cof ( I named mine arborhub.conf) file.

So I configured my nginx.conf file, here

server {
         listen 192.xxx.x.xxx:80;
         server_name arborhub.io 192.xxx.x.xxx;

         location / {
                 include proxy_params;
                 proxy_pass http://unix:/home/ubuntu/MyProject/app.sock;
         }
         location /static/ {
                 autoindex on;
                 alias /home/ubuntu/MyProject/static/;
         }
         location /media/ {
                 autoindex on;
                 alias /home/ubuntu/MyProject/media/;
   }
}

So I’m still new to Nginx. When end-users on the client-side, type in my app domain name, arborhub.io, they can access my website.

But when I configured nginx server and typed in the IP address in the search bar, it went directly to the default nginx page.

But if I type in my domain name in the address bar, it doesn’t load the nginx page.

My questions are:

  1. How do configure the file so that I can load the page in the browser with my domain name?
  2. I have a Django backend project, which is always localhost, on port 8000. With this configuration, will always direct traffic to my Django backend? I haven’t set up a reverse proxy yet, which as I understand it, acts as a firewall between the client and my web servers

For example, here is the screenshot for the nginx default page when I type in the IP address on the address bar. Here is the screenshot when I type in www.arborhub.io

In other words, I want the page to not display the default page, but to display my backend Django project

Moving this to the "How Do I...?" category.

Can you check if you still have a default.conf configuration in your nginx config dir? Chances are that file is there, which is serving the default welcome to nginx page, and it is setup as the default server(ie any request that does not have a DNS name associated with it will be processed by that configuration). If you remove that file and restart the nginx service, you should be able to access your application via the IP address.

As for the www not loading, you will need to add www.arborhub.io to the server_name line and make sure that the DNS is pointed to the correct IP.

1 Like