Skip to content

Server Static Sites

Example:

Nginx Configuration File
server {
  listen 80;
  listen [::]:80;
  server_name some.domain.com;
  rewrite ^ https://$http_host$request_uri? permanent;
}

server {

  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name some.domain.com;

  index index.html index.php;
  client_max_body_size 256M;

  error_log  /var/log/nginx/some.domain.com_error.log;
  access_log /var/log/nginx/some.domain.com_access.log;


        root /var/www/html;

    location / {
      
    try_files $uri $uri/ /index.html?$query_string;
#    try_files $uri $uri/ /index.php?$query_string;   # if is index.php
        autoindex on;
        } 

  add_header Content-Security-Policy upgrade-insecure-requests;

# path to ssl certs
  ssl_certificate /ssl/some.pem;
  ssl_certificate_key /ssl/some.key;
#  ssl_dhparam /ssl/dhparam-2048.pem;

  ssl_session_timeout 5m;
  ssl_session_cache shared:SSL:5m;

  #SSL Security
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
  #XP and IE6 support
  ssl_ecdh_curve secp384r1;
  ssl_prefer_server_ciphers on;
  ssl_session_tickets off;

  proxy_set_header X-Forwarded-For $remote_addr;

  #Compress and optimize delivery of files

  gzip on;
  gzip_comp_level    5;
  gzip_min_length    256;
  gzip_vary          on;
  gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/ld+json
    application/manifest+json
    application/rss+xml
    application/vnd.geo+json
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/bmp
    image/svg+xml
    image/x-icon
    text/cache-manifest
    text/css
    text/plain
    text/vcard
    text/vnd.rim.location.xloc
    text/vtt
    text/x-component
    text/x-cross-domain-policy;
    # text/html is always compressed by gzip module

}