I am setting up a hobby web site and trying to make it as secure as possible. The backend is nginx + uwsgi. I have set up the HTTPS connection. For non-SSL requests, I have the following rules in nginx.conf:
server {
listen 80;
server_name xxx.net;
return 301 https://xxx.net$request_uri;
}
server {
listen 80;
server_name www.xxx.net;
return 301 https://xxx.net$request_uri;
}
So all http:// requests are 301-redirected to https://. The site is also configured to use HSTS, so browsers will do 306-redirect after the first visit.
In parallel, following some other security-oriented reading, I also set up the UFW firewall to deny access to port 80 (HTTP default). I wonder if that extra step actually adds anything security-wise and doesn't instead introduce confusion?
Will firewall block any HTTP-traffic before nginx has a chance to take over and redirect, or does the redirect happen first? If the redirect does happen, does this rule add anything? Is it a good practice (as an extra security layer) or completely redundant?