## # # See: /etc/nginx/sites-available/ # # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # https://www.nginx.com/resources/wiki/start/ # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ # https://wiki.debian.org/Nginx/DirectoryStructure # # Admins should put this file in /etc/nginx/sites-available/ # and then put a link to it from /etc/nginx/sites-enabled/ # # This file will automatically load configuration files provided by other # applications, such as Drupal or Wordpress. These applications will be made # available underneath a path with that package name, such as /drupal8. # # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; listen [::]:443 ssl; listen 443 ssl; server_name us.metamath.org; root /var/www/us.metamath.org/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; # Don't reveal server version# to attacker mass scans. # https://scotthelme.co.uk/hardening-your-http-response-headers/#x-content-type-options server_tokens off; location / { # We only serve data, so don't allow anything else. limit_except GET HEAD OPTIONS { deny all; } # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Enable CORS so web browser apps can request our data. # https://enable-cors.org/server_nginx.html add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, HEAD, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; # Add some security headers as suggested by # https://securityheaders.com/?q=us.metamath.org&followRedirects=on # https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/ add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';" always; # Counter clickjacking attacks via framebusting. See: # https://scotthelme.co.uk/hardening-your-http-response-headers/#x-frame-options add_header X-Frame-Options "SAMEORIGIN" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # We don't use these, so tell the browser never to allow them in our pages. add_header Permissions-Policy "fullscreen=(), geolocation=(), camera=(), microphone=(), bluetooth=(), usb=()" always; # Harden per https://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; } # pass PHP scripts to FastCGI server # #location ~ \.php$ { # include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): # fastcgi_pass unix:/run/php/php7.3-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} # TLS certificates managed by Certbot for Let's Encrypt. ssl_certificate /etc/letsencrypt/live/us.metamath.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/us.metamath.org/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; } server { listen 80 ; listen [::]:80 ; server_name us.metamath.org; # Don't reveal server version# to attacker mass scans. # https://scotthelme.co.uk/hardening-your-http-response-headers/#x-content-type-options server_tokens off; location / { # We only serve data, so don't allow anything else. limit_except GET HEAD OPTIONS { deny all; } # Harden per https://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; } # Use 302 for temporary redirect, use 301 to tell people "use HTTPS". return 301 https://$host$request_uri; }