offer.conf 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Cache zone
  2. proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC:10m inactive=7d use_temp_path=off;
  3. upstream nextjs {
  4. server 127.0.0.1:3000;
  5. }
  6. upstream palizvaniback {
  7. server palizvani.hghweb.ir;
  8. }
  9. server {
  10. listen 46.245.80.114:443 ssl http2 backlog=1048576 reuseport;
  11. # listen 80 default_server;
  12. include /config/ssl-nginx.conf;
  13. server_name palizvani.ir www.palizvani.ir ;
  14. add_header 'Access-Control-Allow-Origin' $http_origin always;
  15. add_header 'Access-Control-Allow-Credentials' 'true' always;
  16. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
  17. 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;
  18. proxy_buffering off;
  19. proxy_http_version 1.1;
  20. # Pass some headers to the downstream server, so it can identify the host.
  21. proxy_set_header Host $http_host;
  22. proxy_set_header Range $http_range;
  23. proxy_set_header If-Range $http_if_range;
  24. proxy_set_header X-Nginx-Proxy true;
  25. proxy_set_header X-Request-Id $request_id;
  26. proxy_set_header REMOTE_ADDR $remote_addr;
  27. #These header fields are required if your application is using Websockets.
  28. proxy_set_header Upgrade $http_upgrade;
  29. proxy_set_header Connection $connection_upgrade;
  30. proxy_set_header X-Real-IP $remote_addr;
  31. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  32. # Tell any web apps like Drupal that the session is HTTPS.
  33. proxy_set_header X-Forwarded-Proto $scheme;
  34. proxy_redirect off;
  35. #The proxy interface to the backend should not compress the data (lan connection).
  36. proxy_set_header Accept-Encoding "";
  37. server_tokens off;
  38. gzip on;
  39. gzip_proxied any;
  40. gzip_comp_level 4;
  41. gzip_types text/css application/javascript image/svg+xml;
  42. location / {
  43. # limit_req zone=req_zone_alaatv burst=100 nodelay;
  44. limit_req_status 429;
  45. # limit_conn con_zone_alaatv 64;
  46. proxy_pass_request_headers on;
  47. proxy_pass http://nextjs;
  48. }
  49. location ~ ^/api/(.*)$ {
  50. # limit_req zone=req_zone_soalaa burst=50 nodelay;
  51. limit_req_status 429;
  52. proxy_redirect off;
  53. proxy_set_header Host $host;
  54. proxy_set_header X-Forwarded-Host $host;
  55. proxy_set_header X-Forwarded-Server $host;
  56. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  57. proxy_http_version 1.1;
  58. proxy_pass_request_headers on;
  59. proxy_set_header Connection "keep-alive";
  60. proxy_store off;
  61. proxy_pass http://palizvaniback/api/$1?$query_string;
  62. }
  63. location ^~ /assets {
  64. add_header X-Cache-Status $upstream_cache_status always;
  65. proxy_pass_request_headers off;
  66. # proxy_cache php_cache;
  67. proxy_buffering on;
  68. proxy_cache_background_update on;
  69. proxy_cache_valid 200 206 302 304 3h;
  70. proxy_cache_key "$scheme$request_method$request_uri$is_args$args";
  71. proxy_cache_revalidate on;
  72. proxy_cache_min_uses 1;
  73. proxy_cache_methods GET HEAD;
  74. proxy_cache_lock on;
  75. proxy_ignore_headers Expires Set-Cookie;
  76. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404 non_idempotent;
  77. proxy_hide_header Cache-Control;
  78. proxy_hide_header etag;
  79. proxy_cache_use_stale updating error timeout invalid_header http_500 http_502 http_503 http_504 http_403 http_429 http_404;
  80. proxy_pass http://nextjs;
  81. expires 365d;
  82. }
  83. location ~* \.(css|ico|woff|woff2|eot|svg|png|jpg|jpeg|gif|json|txt|mp4|mp3|webp|webm|pdf)$ {
  84. access_log off;
  85. log_not_found off;
  86. try_files $uri $uri/ =404;
  87. expires 7d;
  88. }
  89. # PWA
  90. location = /sw.js {
  91. proxy_pass_request_headers on;
  92. proxy_pass http://alaatv-front;
  93. proxy_hide_header Cache-Control;
  94. add_header Cache-Control no-cache;
  95. }
  96. location = /manifest.json {
  97. proxy_pass_request_headers on;
  98. proxy_pass http://alaatv-front;
  99. proxy_hide_header Cache-Control;
  100. add_header Cache-Control no-cache;
  101. }
  102. location ~ /workbox-.+\.js$ {
  103. proxy_pass_request_headers on;
  104. proxy_pass http://alaatv-front;
  105. proxy_hide_header Cache-Control;
  106. add_header Cache-Control no-cache;
  107. }
  108. }