
user  root;
worker_processes  1;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/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;

    sendfile        on;
    #tcp_nopush     on;

    client_max_body_size 50M;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  cdc.iitdh.ac.in;

        listen       443 ssl;
    #    server_name  localhost;

       ssl_certificate      /home/cdc/Desktop/1f9476e3959ebe60.pem;
       ssl_certificate_key  /home/cdc/Desktop/star_iitdh_key.key;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        
        location / {
            root   /usr/share/nginx/html;
           try_files $uri $uri/ /portal;
        }

        location /portal {
            root   /usr/share/nginx/html;
        index index.html;
        try_files $uri $uri/ /portal/index.html;
        }

        # Server static files /storage
        location /storage {
            alias '/home/gowtham/Gowtham/Projects/cdc-placement-website-backend/CDC_Backend/Storage/';
            autoindex on;
            autoindex_exact_size on;
        }

        location /static {
            autoindex on;
            autoindex_exact_size on;
            alias '/home/gowtham/Gowtham/Projects/cdc-placement-website-backend/CDC_Backend/static/';
        }

        location /api/ {
            proxy_pass https://localhost:8000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
        }
        location /admin/ {
            proxy_pass https://localhost:8000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
        }



        #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   html;
        }
}

}
