limit_req_zone $binary_remote_addr$request_uri zone=req_zone_alaatv:100m rate=50r/s; limit_conn_zone $binary_remote_addr zone=con_zone_alaatv:100m; map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream alaatv-front { least_conn; zone upstream-alaatv-front 1024k; server 127.0.0.1:19080 max_fails=0; server 127.0.0.1:19080 max_fails=0; server 127.0.0.1:19080 max_fails=0; keepalive 4; } upstream nginx-alaatv { least_conn; zone upstream-nginx-alaatv 1024k; server 127.0.0.1:8080 max_fails=0; server 127.0.0.2:8080 max_fails=0; keepalive 4; } server { listen 46.245.80.114:80; server_name alaatv.com www.alaatv.com; error_log /dev/null crit; access_log off; add_header 'Access-Control-Allow-Origin' $http_origin always; add_header Set-Cookie $http_cookie; return 301 https://alaatv.com$request_uri; } server { listen 46.245.80.114:443 ssl http2; server_name www.alaatv.com; error_log /dev/null crit; access_log off; include /config/ssl-alaatv-nginx.conf; add_header 'Access-Control-Allow-Origin' $http_origin always; add_header Set-Cookie $http_cookie; return 301 https://alaatv.com$request_uri; } server { listen 46.245.80.114:443 ssl http2; server_name 46.245.80.114; error_log /dev/null crit; include /config/ssl-alaatv-nginx.conf; add_header Set-Cookie $http_cookie; return 302 https://alaatv.com$request_uri; } ##SSL OFFLOAD server { listen 46.245.80.114:443 ssl http2 backlog=1048576 reuseport; server_name alaatv.com; root /home/alaa/alaatv/public; access_log /var/log/nginx/ssl.full-access.log full; error_log /var/log/nginx/ssl.error.log error; include /config/ssl-alaatv-nginx.conf; add_header 'Access-Control-Allow-Origin' $http_origin always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always; proxy_buffering off; proxy_http_version 1.1; # Pass some headers to the downstream server, so it can identify the host. proxy_set_header Host $http_host; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_set_header X-Nginx-Proxy true; proxy_set_header X-Request-Id $request_id; proxy_set_header REMOTE_ADDR $remote_addr; #These header fields are required if your application is using Websockets. proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Tell any web apps like Drupal that the session is HTTPS. proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; #The proxy interface to the backend should not compress the data (lan connection). proxy_set_header Accept-Encoding ""; location ~ ^/alaa/api/v2/(.*)$ { limit_req zone=req_zone_soalaa burst=50 nodelay; limit_req_status 429; proxy_redirect off; proxy_set_header Host $host; 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_http_version 1.1; proxy_pass_request_headers on; proxy_set_header Connection "keep-alive"; proxy_store off; proxy_pass http://nginx-alaatv/api/v2/$1?$query_string; } location ~ ^/alaa/api/v1/(.*)$ { limit_req zone=req_zone_soalaa burst=50 nodelay; limit_req_status 429; proxy_redirect off; proxy_set_header Host $host; 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_http_version 1.1; proxy_pass_request_headers on; proxy_set_header Connection "keep-alive"; proxy_store off; proxy_pass http://nginx-alaatv/api/v1/$1?$query_string; } location ^~ /assets { add_header X-Cache-Status $upstream_cache_status always; proxy_pass_request_headers off; proxy_cache php_cache; proxy_buffering on; proxy_cache_background_update on; proxy_cache_valid 200 206 302 304 3h; proxy_cache_key "$scheme$request_method$request_uri$is_args$args"; proxy_cache_revalidate on; proxy_cache_min_uses 1; proxy_cache_methods GET HEAD; proxy_cache_lock on; proxy_ignore_headers Expires Set-Cookie; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404 non_idempotent; proxy_hide_header Cache-Control; proxy_hide_header etag; proxy_cache_use_stale updating error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_429 http_404; proxy_pass http://alaatv-front; expires 365d; } location = /najva-messaging-sw.js { proxy_pass_request_headers on; proxy_pass http://alaatv-front; proxy_hide_header Cache-Control; add_header Cache-Control no-cache; } location = /sw.js { proxy_pass_request_headers on; proxy_pass http://alaatv-front; proxy_hide_header Cache-Control; add_header Cache-Control no-cache; } location = /manifest.json { proxy_pass_request_headers on; proxy_pass http://alaatv-front; proxy_hide_header Cache-Control; add_header Cache-Control no-cache; } location ~ /workbox-.+\.js$ { proxy_pass_request_headers on; proxy_pass http://alaatv-front; proxy_hide_header Cache-Control; add_header Cache-Control no-cache; } location ~ /icons { add_header X-Cache-Status $upstream_cache_status always; proxy_pass_request_headers off; proxy_cache php_cache; proxy_buffering on; proxy_cache_background_update on; proxy_cache_valid 200 206 302 304 3h; proxy_cache_key "$scheme$request_method$request_uri$is_args$args"; proxy_cache_revalidate on; proxy_cache_min_uses 1; proxy_cache_methods GET HEAD; proxy_cache_lock on; proxy_ignore_headers Expires Set-Cookie; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404 non_idempotent; proxy_hide_header Cache-Control; proxy_hide_header etag; proxy_cache_use_stale updating error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_429 http_404; proxy_pass http://alaatv-front; expires 30d; } location ~* \.(css|ico|woff|woff2|eot|svg|png|jpg|jpeg|gif|json|txt|mp4|mp3|webp|webm|pdf)$ { access_log off; log_not_found off; try_files $uri $uri/ =404; expires 7d; } location = /sping { return 200 'ssl-nginx-PONG!: $http_upgrade'; add_header Content-Type text/plain; } location = /ping { proxy_pass_request_headers off; proxy_pass http://nginx-alaatv; } location /landing/penalty { limit_req zone=req_zone_alaatv burst=100 nodelay; limit_req_status 429; limit_conn con_zone_alaatv 64; proxy_pass_request_headers on; proxy_pass http://nginx-alaatv; } location /js { limit_req zone=req_zone_alaatv burst=100 nodelay; limit_req_status 429; limit_conn con_zone_alaatv 64; proxy_pass_request_headers on; proxy_pass http://nginx-alaatv; } location /css { limit_req zone=req_zone_alaatv burst=100 nodelay; limit_req_status 429; limit_conn con_zone_alaatv 64; proxy_pass_request_headers on; proxy_pass http://nginx-alaatv; } location /api { limit_req zone=req_zone_alaatv burst=100 nodelay; limit_req_status 429; limit_conn con_zone_alaatv 64; proxy_pass_request_headers on; proxy_redirect off; proxy_set_header Host $host; 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_http_version 1.1; proxy_set_header Connection "keep-alive"; proxy_store off; proxy_pass http://nginx-alaatv; } location /ajax { limit_req zone=req_zone_alaatv burst=100 nodelay; limit_req_status 429; limit_conn con_zone_alaatv 64; proxy_pass http://nginx-alaatv; } location / { limit_req zone=req_zone_alaatv burst=100 nodelay; limit_req_status 429; limit_conn con_zone_alaatv 64; proxy_pass_request_headers on; proxy_pass http://alaatv-front; } }