worker_processes auto;

events {
	worker_connections 1024;
}

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

	sendfile on;
	keepalive_timeout 65;

	upstream frontend_upstream {
		server frontend:80;
	}

	upstream backend_upstream {
		server backend:8000;
	}

	server {
		listen 80;
		server_name _;

		location /api/ {
			proxy_pass http://backend_upstream;
			proxy_http_version 1.1;
			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;
		}

		location / {
			proxy_pass http://frontend_upstream;
			proxy_http_version 1.1;
			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;
		}
	}
}
