server{
    listen 80;
    server_name 31.7.74.79;
    return 301 https://igarson.app;
}

server {
    listen 443;
    server_name 31.7.74.79;
    return 301 https://igarson.app;
}

server{
        server_name igarson.app  www.igarson.app;
        access_log /var/log/nginx/ig/access.www.log;
        error_log /var/log/nginx/ig/error.www.log;
        error_page 500 502 503 504 https://igarson.app/500;
        error_page 401 403  https://igarson.app/500;
        error_page 404 https://igarson.app/404;

        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8014;
            proxy_read_timeout 90;
            proxy_redirect off;
        }

        location /warehouse/windows {
            auth_request /api/v1/update/windows/validate;
            root /volume/ig/api/storage;
            autoindex on;
        }

        location = /api/v1/update/windows/validate {
            internal;
            proxy_set_header X-Original-URI $request_uri;
            proxy_pass_request_body off;
            proxy_pass http://127.0.0.1:8011;
        }

        location /goto {
            return 302 $arg_dest;

        }
        
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

server{
        server_name api.igarson.app;
        access_log /var/log/nginx/ig/access.api.log;
        error_log  /var/log/nginx/ig/error.api.log;
        client_max_body_size 128M;
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8011;
            proxy_read_timeout 90;
        }

        location /IG {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8011;
            proxy_read_timeout 90;
            proxy_http_version 1.1;
            proxy_set_header Upgrade "websocket";
            proxy_set_header Connection "upgrade";
        }
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/capitan.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/capitan.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
        server_name storage.igarson.app;
        access_log /var/log/nginx/ig/access.storage.log;
        error_log /var/log/nginx/ig/error.storage.log;
        

        location ~ ^/public/.*\.(JPG|ico|jpg|jpeg|gif|png|svg|json)$ {
            root /volume/ig/api/storage;
            add_header        Cache-Control public;
            add_header        Cache-Control must-revalidate;
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
            autoindex on;

        } 

        location ~ .*\.(JPG|ico|jpg|jpeg|gif|png|svg|json)$ {
            root /volume/ig/ls/wwwroot;
            add_header        Cache-Control "public, max-age=86400";
            add_header         Surrogate-Control "public, max-age=86400";
            add_header        Cache-Control must-revalidate;
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
            autoindex on;

        
        }
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/capitan.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/capitan.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server{
        server_name ls.igarson.app;
        access_log /var/log/nginx/ig/access.ls.log;
        error_log /var/log/nginx/ig/error.ls.log;
        client_max_body_size 20M;
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8010;
            proxy_read_timeout 90;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/capitan.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/capitan.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server{
        server_name capitan.igarson.app;
        access_log /var/log/nginx/ig/access.capitan.log;

        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8013;
            proxy_read_timeout 90;
        }
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/demo.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/demo.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

server{
        server_name guardians.of.galaxy.igarson.app;
        access_log /var/log/nginx/ig/access.guardians.of.galaxy.log;
        error_log /var/log/nginx/ig/error.guardians.of.galaxy.log;
        client_max_body_size 10M;
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8015;
            proxy_read_timeout 90;
            proxy_redirect off;
        }
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/capitan.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/capitan.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}




# redirects 
server{
    if ($host = www.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name igarson.app  www.igarson.app;
    listen 80;
    return 404; # managed by Certbot


}

server{
    if ($host = guardians.of.galaxy.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name guardians.of.galaxy.igarson.app;
    listen 80;
    return 404; # managed by Certbot
}

server{
    if ($host = capitan.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name capitan.igarson.app;
    listen 80;
    return 404; # managed by Certbot
}

server{
    if ($host = ls.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name ls.igarson.app;
    listen 80;
    return 404; # managed by Certbot
}

server{
    if ($host = storage.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name storage.igarson.app;
    listen 80;
    return 404; # managed by Certbot
}

server{
    if ($host = api.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name api.igarson.app;
    listen 80;
    return 404; # managed by Certbot
}


server{
        server_name champions.of.galaxy.igarson.app;
        access_log /var/log/nginx/ig/access.champions.of.galaxy.igarson.app.log;
        
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:9000;
            proxy_read_timeout 90;
            proxy_redirect off;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/champions.of.galaxy.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/champions.of.galaxy.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}


server{
    if ($host = champions.of.galaxy.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        server_name champions.of.galaxy.igarson.app;
    listen 80;
    return 404; # managed by Certbot


}

server{
        server_name mail.igarson.app;
        access_log /var/log/nginx/ig/access.mail.igarson.app.log;
        
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:9999;
            proxy_read_timeout 90;
            proxy_redirect off;
            proxy_http_version 1.1;
        }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mail.igarson.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mail.igarson.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server{
    if ($host = mail.igarson.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        server_name mail.igarson.app;
    listen 80;
    return 404; # managed by Certbot


}
server{
        server_name igli.ir;
        access_log /var/log/nginx/ig/access.igli.ir.log;
        
        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://127.0.0.1:8016;
            proxy_read_timeout 90;
            proxy_redirect off;
            proxy_http_version 1.1;
        }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/igli.ir/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/igli.ir/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server{
    if ($host = igli.ir) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        server_name igli.ir;
    listen 80;
    return 404; # managed by Certbot


}
