server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;
    client_max_body_size 12M;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        proxy_pass http://citizen-front:4000/;
    }

    location /api/ {
        proxy_pass http://citizen-back:5002/api/;
    }

    location /api/media/ {
        proxy_pass http://citizen-back:5002/api/media/;
        proxy_intercept_errors on;
        error_page 404 = @media1;
    }

    location /api/media1/ {
        proxy_pass http://media/;
    }

    location @media1 {
        rewrite ^/api/media/(.*)$ /api/media1/$1;
    }

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