Redirect all HTTP traffic to HTTPS¶
server { listen 80; server_name ibtisam-iq.com www.ibtisam-iq.com; # You don’t need to explicitly define location / in the HTTP-to-HTTPS redirect block # because the entire request, regardless of path, will be redirected to https://\(host\)request_uri return 301 https://\(host\)request_uri;
# Handle Let's Encrypt ACME Challenge (for SSL certificate issuance)
# location /.well-known/acme-challenge/ { # root /var/www/html; # try_files $uri =404; # }
# Instead, use the --standalone option to tell Certbot to handle the challenge using its own built-in web server. }
server { listen 443 ssl; server_name ibtisam-iq.com www.ibtisam-iq.com; # WebsiteBuilder Site
ssl_certificate /etc/letsencrypt/live/ibtisam-iq.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ibtisam-iq.com/privkey.pem;
location / {
proxy_pass http://172.31.91.166:8080; # Update with your application’s port
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;
}
}