server {
	listen 80;
	listen [::]:80;
	server_name localhost;

    proxy_read_timeout 600s;
    proxy_send_timeout 600s;

    # set client max upload body size to#
    client_max_body_size 50M;

    location / {
		proxy_pass http://frontend:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 		root /usr/share/nginx/html;
#       index index.html index.htm;
    }

    # API Django backend
    location /api {
        proxy_pass http://indrz_api:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }

    # STATIC files
    location /static {
        alias /opt/data/static/;
        expires 30d;
        access_log off;
        add_header Cache-Control "public";
    }

    # MEDIA backend uploads
    location /media {
        alias /opt/data/media/;
    }

    # GEOSERVER mapserver and maptiles
    location /geoserver {
        proxy_pass http://geoserver:8080/geoserver;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        port_in_redirect off;
        proxy_connect_timeout 600;
        proxy_set_header X-Script-Name /geoserver;
    }


    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

}