By leninmishra
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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 to reporting.x.com?
Restart Nginx after setting your conf by running:
systemctl restart nginx
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.
server {
listen 80;
server_name <ip-address> .X.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/eleena/reporting_app;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/eleena/reporting_app.sock;
}
The dot in front of X.com is not a typo. This basically says any sub domain for X.com.
settings.py file in Django AppYou have to set ALLOWED_HOSTS this way.
ALLOWED_HOSTS = ['ip-address', '.X.com']
Again X.com is preceded with a dot.
In the question, I already mentioned that I created an A record with following details.
Host- reporting
Type - A
Content - <ip-address> of digital ocean droplet
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.