Created
January 19, 2023 11:18
-
-
Save davidofug/c6b8eb6e072a769c3aaf5722117ade1e to your computer and use it in GitHub Desktop.
Code Step-by-Step Guide on Connecting Your Django App to a Custom Domain Name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Navigate to the Nginx server directive directory. | |
cd /etc/nginx/conf.d/ | |
or | |
/etc/nginx/sites-available/ | |
# 2. Create a the Server block configuration file. | |
sudo nano domain.com.conf | |
# 3. Add configuration code to the configuration file and save. | |
# This is a comment | |
server { | |
# Listen on port 80 | |
listen 80; | |
# Server name | |
server_name domain.com; | |
location / { | |
# Proxy pass to Django server on localhost:8000 | |
proxy_pass http://127.0.0.1:8000; | |
# Set headers | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
} | |
# 4. Test the configuration | |
sudo nginx -t | |
# 5. If all is good, restart the nginx service | |
sudo systemctl restart nginx | |
or | |
sudo service nginx restart | |
# well done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment