#
# SoftWLC 1.9, EMS 3.13 server configuration
#

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=eltex_cache:32m max_size=5g inactive=60m use_temp_path=off;

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    listen 8080;
    listen [::]:8080;

    # SSL configuration
    #    listen 8443 ssl;
    #    listen [::]:8443 ssl;
    gzip off;

    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    #    ssl_certificate "путь_к_сертификату" 
    #    ssl_certificate_key "путь_к_приватному_ключу";
    
    # server_name имя_сервера ;

    # eltex-portal

    location ~* /eltex_portal/(gif|jpeg|jpg|png|svg|js|css)/ {
        proxy_cache eltex_cache;
        proxy_cache_revalidate on;
        proxy_cache_min_uses 3;
        proxy_ignore_headers Cache-Control Expires;
        proxy_cache_valid any 1h;

        # uncomment this if nignx version >= 1.11.10.
        #proxy_cache_use_stale error timeout updating http_500 http_502
        #                      http_503 http_504;
        #proxy_cache_background_update on; 
        proxy_cache_lock on;
        # адрес портала
        proxy_pass http://127.0.0.1:9000;

    }

     location ~* /eltex_portal/portal/ {
        proxy_cache eltex_cache;
        proxy_ignore_headers Cache-Control Expires;
        proxy_cache_valid 404 302 304 5m;
        proxy_cache_valid any 1h;
        proxy_cache_lock on;
        # адрес портала
        proxy_pass http://127.0.0.1:9000;
     }

    location /eltex_portal/ {
        # адрес портала
        proxy_pass http://127.0.0.1:9000;
    }

    # epadmin

    location /epadmin/(gif|jpeg|jpg|svg|png|js|css)/ {
        # адрес tomcat
        proxy_cache eltex_cache;
        proxy_cache_min_uses 3;
        proxy_cache_valid any 1h;
        proxy_pass http://127.0.0.1:8081;
    }

    location /epadmin/ {
        # адрес tomcat
        proxy_pass http://127.0.0.1:8081;
    }

    location /ep-demo {
        # адрес tomcat
        proxy_pass http://127.0.0.1:8081;
    }

    # wifi-cab

    location /wifi-cab {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        # адрес tomcat
        proxy_pass http://127.0.0.1:8081;
    }

    location /wifi-cab/PUSH {
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection $connection_upgrade;
       proxy_buffering off;
       proxy_ignore_client_abort off;
       proxy_read_timeout 84600s;
       proxy_send_timeout 84600s;
       # адрес tomcat
       proxy_pass http://127.0.0.1:8081/wifi-cab/PUSH;
    }

    # nbi

    location /axis2 {
        # адрес tomcat
        proxy_pass http://127.0.0.1:8081;
    }

    location /northbound {
        proxy_pass http://127.0.0.1:8081;
    }

    location /eltex-radius-nbi {
        proxy_pass http://127.0.0.1:8081;
    }


    # ems
    
    location /ems {
        proxy_set_header Host $http_host;
        # адрес tomcat
        proxy_pass http://127.0.0.1:8081;
    }

    location /ems_files {
        proxy_pass http://127.0.0.1:8081;
    }


    # deny root

    # опционально запрещаем доступ в корень
    location / { 
        deny all; 
    }
}
