## # Settings For www Subdomain ## # server { # # Redirects from domain with www to plain domain without www # server_name www.example.com; # return 301 $scheme://$host$request_uri; # } ## # Settings For Domain ## server { ## # SSL configuration ## # Uncomment this block if your server has an SSL certificate, # and comment or remove the two listen 80 directives under it # # 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 # # listen 443 ssl http2; # listen [::]:443 ssl http2; # ssl_certificate /etc/nginx/ssl/example.com.crt; # ssl_certificate_key /etc/nginx/ssl/example.com.key; listen 80; listen [::]:80; root /var/www/example.com/html; # The folder that stores the website's contents index index.php index.html index.htm; # Tries to find an index file matching any of these, in order server_name example.com; # return 301 https://$host$request_uri; # Redirects from HTTP to HTTPS ## # Error-handling ## error_page 405 =200 $uri; # Allows POST on static pages ## # Buffers ## client_body_buffer_size 16k; # Buffer size for the request body. 16k for 64-bit systems and 8k for 32-bit systems client_max_body_size 10M; # Max file upload size. Increase if 10 MB is not enough client_body_in_single_buffer on; # Stores the complete request buffer in a single buffer client_header_buffer_size 1M; # Size of the allocated buffer for request headers large_client_header_buffers 4 8k; # Maximum number and size for reading large request headers. client_header_timeout 5s; # Timeout for client header client_body_timeout 5s; # Timeout for client body ## # Settings For All Contents ## location / { autoindex off; # Disables directory listing # First attempts to serve request as file, then # as directory, then calls index.php (for WordPess permalinks), # then falls back to displaying a 404. try_files $uri $uri/ /index.php$is_args$args =404; } # # Pass PHP scripts to FastCGI server # # (Uncomment this section if you're running a PHP application, # # and remove the =404 from the above section) # location ~ \.php$ { # include snippets/fastcgi-php.conf; # # With php-fpm (or other unix sockets, would probably be your first option): # fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # # With php-cgi (or other tcp sockets): # # fastcgi_pass 127.0.0.1:9000; # } # Denies access to hidden files except for .well-known location ~ /\.(?!well-known).* { deny all; } # Denies access to temporary files location ~ ~$ { deny all; } # Excludes favicon from access log location = /favicon.ico { log_not_found off; access_log off; } # Excludes robots.txt from access log location = /robots.txt { log_not_found off; access_log off; allow all; } # Caches certain files and excludes them from not found log location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ { expires max; log_not_found off; } # Custom 404 error page # error_page 404 /404.html; # location = /404.html { # internal; # } }