
#user  nobody;
worker_processes  1;

# This default error log path is compiled-in to make sure configuration parsing
# errors are logged somewhere, especially during unattended boot when stderr
# isn't normally logged anywhere. This path will be touched on every nginx
# start regardless of error log location configured here. See
# https://trac.nginx.org/nginx/ticket/147 for more info. 
#
#error_log  /var/log/nginx/error.log;
#

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       0.0.0.0:80;
        listen       [::]:80;
        server_name  auto.ahlawat.com auto;

        location / {
            root   /usr/local/www/nginx;
            index  index.html index.htm;
        }
    }



    server {
        listen       0.0.0.0:80;
        listen       [::]:80;
        server_name  portfolio.ahlawat.com portfolio;

        location / {
            add_header alt-svc 'h3=":443"';
            return 301 https://portfolio.ahlawat.com$request_uri;
        }
    }

    server {
        listen      0.0.0.0:443 ssl http2;
        listen      0.0.0.0:443 http3 reuseport;
        listen      [::]:443 ssl http2;
        listen      [::]:443 http3 reuseport;
        server_name portfolio.ahlawat.com;

        add_header alt-svc 'h3=":443"';

        ssl_certificate      /mnt/certs/fullchain.pem;
        ssl_certificate_key  /mnt/certs/privkey.pem;

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

#        ssl_ciphers  HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers  on;

        # modern configuration
        ssl_protocols TLSv1.3;
        ssl_prefer_server_ciphers off;

        # HSTS (ngx_http_headers_module is required) (63072000 seconds)
        add_header Strict-Transport-Security "max-age=63072000" always;

        # OCSP stapling
        ssl_stapling on;
        ssl_stapling_verify on;

        # verify chain of trust of OCSP response using Root CA and Intermediate certs
        ssl_trusted_certificate /mnt/certs/fullchain.pem;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root   /data/portfolio;
        }
        location /media/ {
            root   /data/portfolio;
        }
        location / {
            proxy_pass  http://unix:/var/run/portfolio.sock;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }



    server {
        listen       0.0.0.0:80;
        listen       [::]:80;
        server_name  producthunt.ahlawat.com producthunt;

        location / {
            return 301 https://producthunt.ahlawat.com$request_uri;
        }
    }

    server {
        listen      0.0.0.0:443 ssl http2;
        listen      [::]:443 ssl http2;
        server_name producthunt.ahlawat.com;

        ssl_certificate      /mnt/certs/fullchain.pem;
        ssl_certificate_key  /mnt/certs/privkey.pem;

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

#        ssl_ciphers  HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers  on;

        # modern configuration
        ssl_protocols TLSv1.3;
        ssl_prefer_server_ciphers off;

        # HSTS (ngx_http_headers_module is required) (63072000 seconds)
        add_header Strict-Transport-Security "max-age=63072000" always;

        # OCSP stapling
        ssl_stapling on;
        ssl_stapling_verify on;

        # verify chain of trust of OCSP response using Root CA and Intermediate certs
        ssl_trusted_certificate /mnt/certs/fullchain.pem;

        #access_log  logs/host.access.log  main;

        location /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root   /data/producthunt;
        }
        location /media/ {
            root   /data/producthunt;
        }
        location / {
            proxy_pass  http://unix:/var/run/producthunt.sock;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
    }



    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

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

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
