alaa-nginx.conf 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. limit_req_zone $binary_remote_addr$request_uri zone=req_zone_alaatv:100m rate=50r/s;
  2. limit_conn_zone $binary_remote_addr zone=con_zone_alaatv:100m;
  3. map $http_upgrade $connection_upgrade {
  4. default upgrade;
  5. '' close;
  6. }
  7. upstream alaatv-front {
  8. least_conn;
  9. zone upstream-alaatv-front 1024k;
  10. server 127.0.0.1:19080 max_fails=0;
  11. server 127.0.0.1:19080 max_fails=0;
  12. server 127.0.0.1:19080 max_fails=0;
  13. keepalive 4;
  14. }
  15. upstream nginx-alaatv {
  16. least_conn;
  17. zone upstream-nginx-alaatv 1024k;
  18. server 127.0.0.1:8080 max_fails=0;
  19. server 127.0.0.2:8080 max_fails=0;
  20. keepalive 4;
  21. }
  22. server {
  23. listen 46.245.80.114:80;
  24. server_name alaatv.com www.alaatv.com;
  25. error_log /dev/null crit;
  26. access_log off;
  27. add_header 'Access-Control-Allow-Origin' $http_origin always;
  28. add_header Set-Cookie $http_cookie;
  29. return 301 https://alaatv.com$request_uri;
  30. }
  31. server {
  32. listen 46.245.80.114:443 ssl http2;
  33. server_name www.alaatv.com;
  34. error_log /dev/null crit;
  35. access_log off;
  36. include /config/ssl-alaatv-nginx.conf;
  37. add_header 'Access-Control-Allow-Origin' $http_origin always;
  38. add_header Set-Cookie $http_cookie;
  39. return 301 https://alaatv.com$request_uri;
  40. }
  41. server {
  42. listen 46.245.80.114:443 ssl http2;
  43. server_name 46.245.80.114;
  44. error_log /dev/null crit;
  45. include /config/ssl-alaatv-nginx.conf;
  46. add_header Set-Cookie $http_cookie;
  47. return 302 https://alaatv.com$request_uri;
  48. }
  49. ##SSL OFFLOAD
  50. server {
  51. listen 46.245.80.114:443 ssl http2 backlog=1048576 reuseport;
  52. server_name alaatv.com;
  53. root /home/alaa/alaatv/public;
  54. access_log /var/log/nginx/ssl.full-access.log full;
  55. error_log /var/log/nginx/ssl.error.log error;
  56. include /config/ssl-alaatv-nginx.conf;
  57. add_header 'Access-Control-Allow-Origin' $http_origin always;
  58. add_header 'Access-Control-Allow-Credentials' 'true' always;
  59. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  60. 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;
  61. proxy_buffering off;
  62. proxy_http_version 1.1;
  63. # Pass some headers to the downstream server, so it can identify the host.
  64. proxy_set_header Host $http_host;
  65. proxy_set_header Range $http_range;
  66. proxy_set_header If-Range $http_if_range;
  67. proxy_set_header X-Nginx-Proxy true;
  68. proxy_set_header X-Request-Id $request_id;
  69. proxy_set_header REMOTE_ADDR $remote_addr;
  70. #These header fields are required if your application is using Websockets.
  71. proxy_set_header Upgrade $http_upgrade;
  72. proxy_set_header Connection $connection_upgrade;
  73. proxy_set_header X-Real-IP $remote_addr;
  74. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  75. # Tell any web apps like Drupal that the session is HTTPS.
  76. proxy_set_header X-Forwarded-Proto $scheme;
  77. proxy_redirect off;
  78. #The proxy interface to the backend should not compress the data (lan connection).
  79. proxy_set_header Accept-Encoding "";
  80. location ~ ^/alaa/api/v2/(.*)$ {
  81. limit_req zone=req_zone_soalaa burst=50 nodelay;
  82. limit_req_status 429;
  83. proxy_redirect off;
  84. proxy_set_header Host $host;
  85. proxy_set_header X-Forwarded-Host $host;
  86. proxy_set_header X-Forwarded-Server $host;
  87. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  88. proxy_http_version 1.1;
  89. proxy_pass_request_headers on;
  90. proxy_set_header Connection "keep-alive";
  91. proxy_store off;
  92. proxy_pass http://nginx-alaatv/api/v2/$1?$query_string;
  93. }
  94. location ~ ^/alaa/api/v1/(.*)$ {
  95. limit_req zone=req_zone_soalaa burst=50 nodelay;
  96. limit_req_status 429;
  97. proxy_redirect off;
  98. proxy_set_header Host $host;
  99. proxy_set_header X-Forwarded-Host $host;
  100. proxy_set_header X-Forwarded-Server $host;
  101. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  102. proxy_http_version 1.1;
  103. proxy_pass_request_headers on;
  104. proxy_set_header Connection "keep-alive";
  105. proxy_store off;
  106. proxy_pass http://nginx-alaatv/api/v1/$1?$query_string;
  107. }
  108. location ^~ /assets {
  109. add_header X-Cache-Status $upstream_cache_status always;
  110. proxy_pass_request_headers off;
  111. proxy_cache php_cache;
  112. proxy_buffering on;
  113. proxy_cache_background_update on;
  114. proxy_cache_valid 200 206 302 304 3h;
  115. proxy_cache_key "$scheme$request_method$request_uri$is_args$args";
  116. proxy_cache_revalidate on;
  117. proxy_cache_min_uses 1;
  118. proxy_cache_methods GET HEAD;
  119. proxy_cache_lock on;
  120. proxy_ignore_headers Expires Set-Cookie;
  121. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404 non_idempotent;
  122. proxy_hide_header Cache-Control;
  123. proxy_hide_header etag;
  124. proxy_cache_use_stale updating error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_429 http_404;
  125. proxy_pass http://alaatv-front;
  126. expires 365d;
  127. }
  128. location = /najva-messaging-sw.js {
  129. proxy_pass_request_headers on;
  130. proxy_pass http://alaatv-front;
  131. proxy_hide_header Cache-Control;
  132. add_header Cache-Control no-cache;
  133. }
  134. location = /sw.js {
  135. proxy_pass_request_headers on;
  136. proxy_pass http://alaatv-front;
  137. proxy_hide_header Cache-Control;
  138. add_header Cache-Control no-cache;
  139. }
  140. location = /manifest.json {
  141. proxy_pass_request_headers on;
  142. proxy_pass http://alaatv-front;
  143. proxy_hide_header Cache-Control;
  144. add_header Cache-Control no-cache;
  145. }
  146. location ~ /workbox-.+\.js$ {
  147. proxy_pass_request_headers on;
  148. proxy_pass http://alaatv-front;
  149. proxy_hide_header Cache-Control;
  150. add_header Cache-Control no-cache;
  151. }
  152. location ~ /icons {
  153. add_header X-Cache-Status $upstream_cache_status always;
  154. proxy_pass_request_headers off;
  155. proxy_cache php_cache;
  156. proxy_buffering on;
  157. proxy_cache_background_update on;
  158. proxy_cache_valid 200 206 302 304 3h;
  159. proxy_cache_key "$scheme$request_method$request_uri$is_args$args";
  160. proxy_cache_revalidate on;
  161. proxy_cache_min_uses 1;
  162. proxy_cache_methods GET HEAD;
  163. proxy_cache_lock on;
  164. proxy_ignore_headers Expires Set-Cookie;
  165. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404 non_idempotent;
  166. proxy_hide_header Cache-Control;
  167. proxy_hide_header etag;
  168. proxy_cache_use_stale updating error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_429 http_404;
  169. proxy_pass http://alaatv-front;
  170. expires 30d;
  171. }
  172. location ~* \.(css|ico|woff|woff2|eot|svg|png|jpg|jpeg|gif|json|txt|mp4|mp3|webp|webm|pdf)$ {
  173. access_log off;
  174. log_not_found off;
  175. try_files $uri $uri/ =404;
  176. expires 7d;
  177. }
  178. location = /sping {
  179. return 200 'ssl-nginx-PONG!: $http_upgrade';
  180. add_header Content-Type text/plain;
  181. }
  182. location = /ping {
  183. proxy_pass_request_headers off;
  184. proxy_pass http://nginx-alaatv;
  185. }
  186. location /landing/penalty {
  187. limit_req zone=req_zone_alaatv burst=100 nodelay;
  188. limit_req_status 429;
  189. limit_conn con_zone_alaatv 64;
  190. proxy_pass_request_headers on;
  191. proxy_pass http://nginx-alaatv;
  192. }
  193. location /js {
  194. limit_req zone=req_zone_alaatv burst=100 nodelay;
  195. limit_req_status 429;
  196. limit_conn con_zone_alaatv 64;
  197. proxy_pass_request_headers on;
  198. proxy_pass http://nginx-alaatv;
  199. }
  200. location /css {
  201. limit_req zone=req_zone_alaatv burst=100 nodelay;
  202. limit_req_status 429;
  203. limit_conn con_zone_alaatv 64;
  204. proxy_pass_request_headers on;
  205. proxy_pass http://nginx-alaatv;
  206. }
  207. location /api {
  208. limit_req zone=req_zone_alaatv burst=100 nodelay;
  209. limit_req_status 429;
  210. limit_conn con_zone_alaatv 64;
  211. proxy_pass_request_headers on;
  212. proxy_redirect off;
  213. proxy_set_header Host $host;
  214. proxy_set_header X-Forwarded-Host $host;
  215. proxy_set_header X-Forwarded-Server $host;
  216. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  217. proxy_http_version 1.1;
  218. proxy_set_header Connection "keep-alive";
  219. proxy_store off;
  220. proxy_pass http://nginx-alaatv;
  221. }
  222. location /ajax {
  223. limit_req zone=req_zone_alaatv burst=100 nodelay;
  224. limit_req_status 429;
  225. limit_conn con_zone_alaatv 64;
  226. proxy_pass http://nginx-alaatv;
  227. }
  228. location / {
  229. limit_req zone=req_zone_alaatv burst=100 nodelay;
  230. limit_req_status 429;
  231. limit_conn con_zone_alaatv 64;
  232. proxy_pass_request_headers on;
  233. proxy_pass http://alaatv-front;
  234. }
  235. }