How to visit your website using the domain without specifying the port ":5000"

Henry Coder
hellocode
Published in
2 min readNov 13, 2023

--

First of all, you need to ensure that your web server listens on the default HTTP port (80) and HTTPS port (443) and then proxies those requests to your application running on port 5000.

sudo nano /etc/nginx/conf.d/firstweb.conf
 HTTP server block
server {
listen 80;
listen [::]:80;
server_name winjob.ai www.winjob.ai;

location ^~ /.well-known/acme-challenge/ {
root /home/ec2-user/firstweb; # This directory must be the root of your web content for the ACME challenge
allow all; # No restrictions for accessing this location
try_files $uri =404; # Serve files if present, or error
}

# Redirect all other requests to HTTPS
location / {
return 301 https://$server_name$request_uri;
}
}


# HTTPS server block
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name winjob.ai www.winjob.ai;

ssl_certificate /home/ec2-user/.acme.sh/winjob.ai_ecc/fullchain.cer;
ssl_certificate_key /home/ec2-user/.acme.sh/winjob.ai_ecc/winjob.ai.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
# Ensure that requests to the application root URL are proxied to Gunicorn
proxy_pass http://localhost:5000;
# Include proxy headers for forwarding the original host, IP, and protocol used
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Define the max body size for client requests, if needed
client_max_body_size 10M; # Adjust the size as necessary
}

# ... rest of your server block for HTTPS ...
}
sudo nginx -t
sudo systemctl reload nginx

--

--