[Django]-Testing nginx without domain name

41👍

You can just use your VPS’s ip in place of “sample.com”:

server {
    listen 80;
    server_name <your_ip_address>;

    <other stuff>

}

If you haven’t already, you may want to assign a static IP; I believe Digital Ocean gives you some free ones.

2👍

Better solution:
Have fun testing many applications

Set host entry on dev machine (not the server).
/etc/hosts
C:\Windows\System32\drivers\etc\hosts

Add as one Line: ipaddress domain i.e 82.32.45.144 is your vps:

82.32.45.144 sample.com
82.32.45.144 www.sample.com
82.32.45.144 wiki.sample.com
82.32.45.144 shop.sample.com
82.32.45.144 sample.co.uk
82.32.45.144 sample.de
👤Xeaon

0👍

I set a default_server with the server_name: _ in my /etc/nginx/sites-enabled/default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _;

    location / {
        # your config goes here
    }
}

This way all traffic to port 80 gets served by this server configuration unless other rules catch it.

More info: nginx server_name wildcard or catch-all

-3👍

You can configure nginx in an easier way rather than specifying the ip address.
You can just user localhost as server_name like below.
You must still use the ip address in the web browser if this stands for a web app.

server {
    listen 80;
    server_name localhost;

    <other stuff>

}

Leave a comment