server {
    listen 8080;
    error_log /var/log/nginx/error.log notice;
    rewrite_log on;
    resolver 127.0.0.11 valid=30s;    
    set $theia theia;
    set $flaskfetfotos "flaskfetfotos:8080";         
    set $etherpad "etherpad:9001";		 
    location /fotos {
        proxy_ssl_server_name on;
        proxy_ssl_verify off;

        proxy_pass http://$flaskfetfotos;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        #             proxy_set_header REMOTE-USER $http_REMOTE_USER;
#             proxy_set_header X-Forwarded-User $http_REMOTE_USER;
#             proxy_set_header x-forwarded-user $http_REMOTE_USER;
        proxy_set_header Connection "upgrade";

  
    }
    
    location /etherpad {

        rewrite /etherpad/(.*) /$1 break;
        rewrite ^/etherpad$ /etherpad/ permanent;

        proxy_pass http://$etherpad;
        proxy_redirect / /etherpad/;
        proxy_set_header Host $host;
        proxy_buffering off;

    }
    location /dev {
        rewrite_log on;
        rewrite /dev/(.*) /$1 break;
        rewrite ^/dev$ /dev/ permanent;
        proxy_set_header Host $host;
        proxy_set_header Proxy "";
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarde-Proto $scheme;
        
        
        proxy_buffering off;
        proxy_pass http://$theia:3000;
            }
    
    location / {
         proxy_set_header Host $host;
        proxy_set_header Proxy "";
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarde-Proto $scheme;
        
        
        proxy_buffering off;
    
        proxy_pass http://$theia:8000;

    }
}
