Django app without port number
I want to connect a DNS record to my Django app, but I can only connect it to an ip address and not a port number. How can I make sure that you are redirected to the Django app if you browse to just the ip address without the port number?
1 Reply
jhartman
Linode Staff
What you've described is known as a reverse proxy, and you can set that up using a very slim and simple config file as described in the guide below:
In short, you would create a file /etc/nginx/conf.d/$NAME_OF_APP.conf
with the following values:
server {
listen 80;
listen [::]:80;
server_name $DOMAIN_NAME.TLD;
location / {
proxy_pass http://localhost:$APP_PORT_NUM/;
}
}
Swapping in your domain name for $DOMAIN_NAME.TLD
and the port number your app uses for APP_PORT_NUM
, respectively.
My colleague Tim's post covers much of the same basics, but goes much deeper into adding SSL/HTTPS encryption for your app: