We already have a website called X.com
. Now i am building a Django App on a Digital ocean Droplet. i am able to access it using the ip-address.
But we want to have it called reporting.X.com
for sharing it with our users.
On my domain providers, I already added an A
record like the below
Host- reporting
Type - A
Content - <ip-address> of digital ocean droplet
However, I keep getting the following message when i try to access reporting.X.com
.
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Okay I have resolved the issue. So I will answer this for future reference of other people.
You need to check 2 important places.
/etc/nginx/sites-enabled/<your_project>
If you want your django app with just the subdomain, your project file in sites-enabled should look like below.
The
dot
in front ofX.com
is not a typo. This basically says any sub domain forX.com
.settings.py
file in Django AppYou have to set
ALLOWED_HOSTS
this way.ALLOWED_HOSTS = ['ip-address', '.X.com']
AgainX.com
is preceded with adot
.In the question, I already mentioned that I created an
A
record with following details.After this, restart your nginx server.
sudo systemctl restart nginx
Now, theoretically it should work. But if it doesn’t (as it didn’t for me), you have to shutdown and restart your droplet.
sudo shutdown -r now
My Django app started to work after this activity. Hope it helps.
The good news is your A record is pointing to your Droplet and is resolving correctly.
I assume you have created a Nginx conf for your subdomain and set the
server_name
property toreporting.x.com
?Restart Nginx after setting your conf by running:
systemctl restart nginx