Advertisement
Djoin

Nginx config

Jul 24th, 2023 (edited)
1,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 23.54 KB | None | 0 0
  1. nginx -T
  2. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  3. nginx: configuration file /etc/nginx/nginx.conf test is successful
  4. # configuration file /etc/nginx/nginx.conf:
  5. user  www-data;
  6. worker_processes  auto;
  7. worker_priority     -2;
  8.  
  9. error_log  /var/log/nginx/error.log notice;
  10. pid        /var/run/nginx.pid;
  11.  
  12.  
  13. events {
  14.     worker_connections  2048;
  15.     multi_accept on;
  16.     use epoll;
  17. }
  18.  
  19.  
  20. http {
  21.     include       /etc/nginx/mime.types;
  22.     default_type  application/octet-stream;
  23.  
  24.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  25.                       '$status $body_bytes_sent "$http_referer" '
  26.                       '"$http_user_agent" "$http_x_forwarded_for"';
  27.  
  28.     access_log  /var/log/nginx/access.log  main;
  29.  
  30.     sendfile        on;
  31.     aio           on;
  32.     tcp_nopush    on;
  33.  
  34.     keepalive_timeout  45;
  35.     reset_timedout_connection  on;
  36.     client_body_timeout        35;
  37.     send_timeout               30;
  38.  
  39.     open_file_cache max=100000 inactive=20s;
  40.     open_file_cache_valid 45s;
  41.     open_file_cache_min_uses 2;
  42.     open_file_cache_errors on;
  43.  
  44.     include /etc/nginx/conf.d/*.conf;
  45. }
  46.  
  47. # configuration file /etc/nginx/mime.types:
  48.  
  49. types {
  50.     text/html                                        html htm shtml;
  51.     text/css                                         css;
  52.     text/xml                                         xml;
  53.     image/gif                                        gif;
  54.     image/jpeg                                       jpeg jpg;
  55.     application/javascript                           js;
  56.     application/atom+xml                             atom;
  57.     application/rss+xml                              rss;
  58.  
  59.     text/mathml                                      mml;
  60.     text/plain                                       txt;
  61.     text/vnd.sun.j2me.app-descriptor                 jad;
  62.     text/vnd.wap.wml                                 wml;
  63.     text/x-component                                 htc;
  64.  
  65.     image/avif                                       avif;
  66.     image/png                                        png;
  67.     image/svg+xml                                    svg svgz;
  68.     image/tiff                                       tif tiff;
  69.     image/vnd.wap.wbmp                               wbmp;
  70.     image/webp                                       webp;
  71.     image/x-icon                                     ico;
  72.     image/x-jng                                      jng;
  73.     image/x-ms-bmp                                   bmp;
  74.  
  75.     font/woff                                        woff;
  76.     font/woff2                                       woff2;
  77.  
  78.     application/java-archive                         jar war ear;
  79.     application/json                                 json;
  80.     application/mac-binhex40                         hqx;
  81.     application/msword                               doc;
  82.     application/pdf                                  pdf;
  83.     application/postscript                           ps eps ai;
  84.     application/rtf                                  rtf;
  85.     application/vnd.apple.mpegurl                    m3u8;
  86.     application/vnd.google-earth.kml+xml             kml;
  87.     application/vnd.google-earth.kmz                 kmz;
  88.     application/vnd.ms-excel                         xls;
  89.     application/vnd.ms-fontobject                    eot;
  90.     application/vnd.ms-powerpoint                    ppt;
  91.     application/vnd.oasis.opendocument.graphics      odg;
  92.     application/vnd.oasis.opendocument.presentation  odp;
  93.     application/vnd.oasis.opendocument.spreadsheet   ods;
  94.     application/vnd.oasis.opendocument.text          odt;
  95.     application/vnd.openxmlformats-officedocument.presentationml.presentation
  96.                                                      pptx;
  97.     application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  98.                                                      xlsx;
  99.     application/vnd.openxmlformats-officedocument.wordprocessingml.document
  100.                                                      docx;
  101.     application/vnd.wap.wmlc                         wmlc;
  102.     application/wasm                                 wasm;
  103.     application/x-7z-compressed                      7z;
  104.     application/x-cocoa                              cco;
  105.     application/x-java-archive-diff                  jardiff;
  106.     application/x-java-jnlp-file                     jnlp;
  107.     application/x-makeself                           run;
  108.     application/x-perl                               pl pm;
  109.     application/x-pilot                              prc pdb;
  110.     application/x-rar-compressed                     rar;
  111.     application/x-redhat-package-manager             rpm;
  112.     application/x-sea                                sea;
  113.     application/x-shockwave-flash                    swf;
  114.     application/x-stuffit                            sit;
  115.     application/x-tcl                                tcl tk;
  116.     application/x-x509-ca-cert                       der pem crt;
  117.     application/x-xpinstall                          xpi;
  118.     application/xhtml+xml                            xhtml;
  119.     application/xspf+xml                             xspf;
  120.     application/zip                                  zip;
  121.  
  122.     application/octet-stream                         bin exe dll;
  123.     application/octet-stream                         deb;
  124.     application/octet-stream                         dmg;
  125.     application/octet-stream                         iso img;
  126.     application/octet-stream                         msi msp msm;
  127.  
  128.     audio/midi                                       mid midi kar;
  129.     audio/mpeg                                       mp3;
  130.     audio/ogg                                        ogg;
  131.     audio/x-m4a                                      m4a;
  132.     audio/x-realaudio                                ra;
  133.  
  134.     video/3gpp                                       3gpp 3gp;
  135.     video/mp2t                                       ts;
  136.     video/mp4                                        mp4;
  137.     video/mpeg                                       mpeg mpg;
  138.     video/quicktime                                  mov;
  139.     video/webm                                       webm;
  140.     video/x-flv                                      flv;
  141.     video/x-m4v                                      m4v;
  142.     video/x-mng                                      mng;
  143.     video/x-ms-asf                                   asx asf;
  144.     video/x-ms-wmv                                   wmv;
  145.     video/x-msvideo                                  avi;
  146. }
  147.  
  148. # configuration file /etc/nginx/conf.d/admin.site.site.conf:
  149. map $sent_http_content_type $expires {
  150.     "text/html"                 epoch;
  151.     "text/html; charset=utf-8"  epoch;
  152.     default                     off;
  153. }
  154.  
  155. server {
  156.     listen 80;
  157.     server_name             admin.site.site;
  158.     set                     $base /var/www;
  159.     root                    $base/public;
  160.  
  161.     # security
  162.     include                 nginx_configs/security.conf;
  163.  
  164.     # logging
  165.     access_log              /var/log/nginx/admin.site.site.access.log;
  166.     error_log               /var/log/nginx/admin.site.site.error.log warn;
  167.  
  168.     client_max_body_size    200M;
  169.  
  170.     location /storage {
  171.         access_log off;
  172.         expires 7d;
  173.     }
  174.  
  175.     # index.html fallback
  176.     location / {
  177.         expires $expires;
  178.  
  179.         proxy_set_header Host               $host;
  180.         proxy_set_header X-Real-IP          $remote_addr;
  181.         proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
  182.         proxy_set_header X-Forwarded-Proto  $scheme;
  183.         proxy_redirect              off;
  184.         proxy_read_timeout          1m;
  185.         proxy_connect_timeout       1m;
  186.         proxy_pass                  http://127.0.0.1:3001; # set the address of the Node.js
  187.     }
  188.  
  189.     # api fallback
  190.     location /api/ {
  191.         try_files $uri $uri/ /index.php?$query_string;
  192.     }
  193.  
  194.     # auth fallback
  195.     location /auth/ {
  196.         try_files $uri $uri/ /index.php?$query_string;
  197.     }
  198.  
  199.     # handle .php
  200.     location ~* \.php$ {
  201.         fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
  202.         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  203.         fastcgi_param DOCUMENT_ROOT $realpath_root;
  204.         include      nginx_configs/php_fastcgi.conf;
  205.     }
  206. }
  207.  
  208. # configuration file /etc/nginx/nginx_configs/security.conf:
  209. # security headers
  210. #add_header X-XSS-Protection          "1; mode=block" always;
  211. #add_header X-Content-Type-Options    "nosniff" always;
  212. #add_header Referrer-Policy           "no-referrer-when-downgrade" always;
  213. #add_header Content-Security-Policy   "default-src 'self' http: https: ws: wss: data: blob: 'unsafe-inline'; frame-ancestors 'self';" always;
  214. #add_header Permissions-Policy        "interest-cohort=()" always;
  215. #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  216.  
  217. add_header X-Frame-Options "SAMEORIGIN";
  218. add_header X-XSS-Protection "1; mode=block";
  219. add_header X-Content-Type-Options "nosniff";
  220.  
  221. # . files
  222. location ~ /\.(?!well-known) {
  223.     deny all;
  224. }
  225. # configuration file /etc/nginx/nginx_configs/php_fastcgi.conf:
  226. # 404
  227. try_files                     $fastcgi_script_name =404;
  228.  
  229. # default fastcgi_params
  230. include                       fastcgi_params;
  231.  
  232. # fastcgi settings
  233. fastcgi_index                 index.php;
  234. fastcgi_buffers               8 16k;
  235. fastcgi_buffer_size           32k;
  236.  
  237. # fastcgi params
  238. fastcgi_param DOCUMENT_ROOT   $realpath_root;
  239. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  240. fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/";
  241. # configuration file /etc/nginx/fastcgi_params:
  242.  
  243. fastcgi_param  QUERY_STRING       $query_string;
  244. fastcgi_param  REQUEST_METHOD     $request_method;
  245. fastcgi_param  CONTENT_TYPE       $content_type;
  246. fastcgi_param  CONTENT_LENGTH     $content_length;
  247.  
  248. fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  249. fastcgi_param  REQUEST_URI        $request_uri;
  250. fastcgi_param  DOCUMENT_URI       $document_uri;
  251. fastcgi_param  DOCUMENT_ROOT      $document_root;
  252. fastcgi_param  SERVER_PROTOCOL    $server_protocol;
  253. fastcgi_param  REQUEST_SCHEME     $scheme;
  254. fastcgi_param  HTTPS              $https if_not_empty;
  255.  
  256. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  257. fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
  258.  
  259. fastcgi_param  REMOTE_ADDR        $remote_addr;
  260. fastcgi_param  REMOTE_PORT        $remote_port;
  261. fastcgi_param  SERVER_ADDR        $server_addr;
  262. fastcgi_param  SERVER_PORT        $server_port;
  263. fastcgi_param  SERVER_NAME        $server_name;
  264.  
  265. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  266. fastcgi_param  REDIRECT_STATUS    200;
  267.  
  268. # configuration file /etc/nginx/conf.d/site.site.conf:
  269. # cache settings
  270.     include nginx_configs/cache.conf;
  271.  
  272. map $sent_http_content_type $expires {
  273.     "text/html"                 epoch;
  274.     "text/html; charset=utf-8"  epoch;
  275.     default                     off;
  276. }
  277. map $http_user_agent $agent_prefix { default ""; "~^(?<prefix>.{4}).*$" $prefix;}
  278.  
  279. map $http_user_agent $mobile_device {
  280.     default Desktop;
  281.     ~*iPad|iPad.*Mobile|^.*Android.*Nexus(((?:(?!Mobile))|(?:(\s(7|10).+))).)*$|SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1010|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P6810|GT-P7501|Kindle|Silk.*Accelerated|xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617|Android.*\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71)\b|Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|Sony\ Tablet|Sony\ Tablet\ S|SGPT12|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT211|SGPT213|EBRD1101|EBRD1102|EBRD1201|MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010|MediaPad|IDEOS\ S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|IQ310|Fly\ Vision|Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE\ U8GT|Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)|\bL-06C|LG-V900|LG-V909\|Android.*(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468)|Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|Android.*ARCHOS|101G9|80G9|NOVO7|Novo7Aurora|Novo7Basic|NOVO7PALADIN|Transformer|TF101\|PlayBook|RIM\ Tablet|HTC\ Flyer|HTC\ Jetstream|HTC-P715a|HTC\ EVO\ View\ 4G|PG41200|Android.*Nook|NookColor|nook\ browser|BNTV250A|LogicPD\ Zoom2|Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A|bq.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant)|Android.*\b97D\b|Tablet(?!.*PC)|ViewPad7|MID7015|BNTV250A|LogicPD\ Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|hp-tablet|Playstation|TB07STA|TB10STA|TB07FTA|TB10FTA|z1000|Z99\ 2G|z99|z930|z999|z990|z909|Z919|z900|TOUCHPAD.*[78910]|Broncho.*(N701|N708|N802|a710)|Pantech.*P4100|\bN-06D|\bN-08D|T-Hub2|Android.*\bNabi|Playstation.*(Portable|Vita) Tablet;
  282.     ~*SM-N|Tapatalk|PDA|PPC|SAGEM|mmp|pocket|psp|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|wap|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser|LG-P500|iPhone.*Mobile|iPod|iTunes|BlackBerry|\bBB10\b|rim[0-9]+|HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6425|001HT|Inspire\ 4G|Android.*\bEVO\b|Nexus\ One|Nexus\ S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue\ Pro|Dell\ Flash|Dell\ Smoke|Dell\ Mini\ 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b|sony|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|Asus.*Galaxy|PalmSource|Palm|Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature|IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250|\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b|PANTECH|IM-A|VEGA\ PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790|Samsung|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E|GT-I|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-P6810|GT-P7100|GT-S|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R4|SCH-T300|SCH-U|SCS-26UC|SGH-A|SGH-B|SGH-C|SGH-D307|SGH-D|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N|SGH-N7|SGH-P|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T|SGH-U|SGH-V|SGH-X|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N8010|Motorola|\bDroid\b.*Build|DROIDX|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT3|XT502|XT530|XT531|XT532|XT535|XT6|XT7|XT8|XT9 Mobile;
  283. }
  284.  
  285. server {
  286.     listen 80 default_server;
  287.     set $base /var/www;
  288.     root $base/public;
  289.  
  290.     # Security
  291.     include nginx_configs/security.conf;
  292.  
  293.     # Logging
  294.     access_log              /var/log/nginx/site.site.access.log;
  295.     error_log               /var/log/nginx/site.site.error.log warn;
  296.  
  297.     add_header X-Cache $upstream_cache_status;
  298.     add_header X-Backend-Server $hostname;
  299.  
  300.     # Gzip
  301.     include nginx_configs/gzip.conf;
  302.  
  303.     location /healthcheck {
  304.         access_log off;
  305.         return 200 "healthy\n";
  306.     }
  307.  
  308.     rewrite ^/en/(.*)$ https://site.site/$1 permanent;
  309.     location /en {
  310.         return 301 https://site.site;
  311.     }
  312.     rewrite /results/africa/malawi/lilongwe /results/africa/malawi permanent;
  313.     rewrite /results/europe/all-countries/tivat/all-specializations/procedures/aligners /results/europe/montenegro/all-cities/all-specializations/procedures/aligners permanent;
  314.  
  315.     if ($request_uri ~ 'jet-theme-core') {
  316.         return 404;
  317.     }
  318.  
  319.  
  320.     location /storage {
  321.         access_log off;
  322.         add_header Cache-control "public";
  323.         expires 7d;
  324.     }
  325.  
  326.     location ~* /warm/sitemap.*.xml {
  327.         root $base/storage/app/sitemap;
  328.     }
  329.  
  330.     location ~* sitemap.*.xml {
  331.         root $base/storage/app/sitemap/curr;
  332.     }
  333.  
  334.     location /6fa701990472fc283181cb279b89bf40b4bce3-f.txt {
  335.         root $base/storage/app/public;
  336.     }
  337.  
  338.     proxy_buffering on;
  339.     proxy_buffer_size 8000k;
  340.     proxy_buffers 8 8000k;
  341.  
  342.     location / {
  343.  
  344.         expires $expires;
  345.         proxy_set_header Host               $host;
  346.         proxy_set_header X-Real-IP          $remote_addr;
  347.         proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
  348.         proxy_set_header X-Forwarded-Proto  $scheme;
  349.         proxy_http_version          1.1;
  350.         proxy_set_header            Upgrade $http_upgrade;
  351.         proxy_set_header            Connection 'upgrade';
  352.         proxy_redirect              off;
  353.         proxy_read_timeout          1m;
  354.         proxy_connect_timeout       1m;
  355.         proxy_pass                  http://127.0.0.1:3000; # set the address of the Node.js
  356.  
  357.         set $no_cache 0;
  358.  
  359.         #set $ignore_header "Cache-Control" "Expires" "Set-Cookie";
  360.         set $hide_header "Set-Cookie";
  361.  
  362.         if ($request_uri ~* ".js|.css") {
  363.             set $no_cache 1;
  364.         }
  365.  
  366.         if ($request_uri ~* "no_cache=yes") {
  367.           set $no_cache 1;
  368.         }
  369.  
  370.         set $device "D";
  371.         if ($agent_prefix ~* "/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i") {
  372.               set $device "M";
  373.             }
  374.         if ($http_user_agent ~* "/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|FBAN|FBAV|fennec|hiptop|iemobile|ip(hone|od)|Instagram|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i") {
  375.               set $device "M";
  376.             }
  377.  
  378.         proxy_cache dg.proxy;
  379.         proxy_cache_key "$mobile_device|$request_uri|$cookie_currency";
  380.         proxy_cache_valid 200 302 301 304 7200h;
  381.         proxy_cache_valid 404 500 0s;
  382.         proxy_hide_header $hide_header;
  383.         proxy_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
  384.         proxy_cache_bypass $no_cache;
  385.         proxy_no_cache $no_cache;
  386.  
  387.  
  388.         }
  389.  
  390.     # api fallback
  391.     location /api/ {
  392.         try_files $uri $uri/ /index.php?$query_string;
  393.     }
  394.  
  395.     # auth fallback
  396.     location /auth/ {
  397.         try_files $uri $uri/ /index.php?$query_string;
  398.     }
  399.  
  400.     # handle .php
  401.     location ~* \.php$ {
  402.             gzip on;
  403.         fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
  404.         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  405.         fastcgi_param DOCUMENT_ROOT $realpath_root;
  406.             include      nginx_configs/php_fastcgi.conf;
  407.         set $realip $remote_addr;
  408.         if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
  409.           set $realip $1;
  410.         }
  411.         fastcgi_param REMOTE_ADDR $realip;
  412.  
  413.         fastcgi_cache dg.fastcgi;
  414.         fastcgi_cache_key "$request_method|$request_uri|$request_body|$cookie_currency|$http_X_Accept_Currency";
  415.         fastcgi_cache_valid 200 302 301 304 72h;
  416.         fastcgi_cache_methods GET POST HEAD;
  417.         fastcgi_hide_header "Set-Cookie";
  418.         fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
  419.         add_header X-Cached $upstream_cache_status;
  420.         fastcgi_cache_bypass $arg__cache_bypass;
  421.  
  422.     }
  423.  
  424.     location ~ ^/(horizon|vendor|telescope)/ {
  425.             auth_basic "Monitoring Content";
  426.             auth_basic_user_file /etc/nginx/.htpasswd;
  427.             try_files $uri /index.php?$query_string;
  428.     }
  429. }
  430.  
  431. # configuration file /etc/nginx/nginx_configs/cache.conf:
  432. fastcgi_cache_path
  433.     /var/nginx_cache/fastcgi_cache
  434.     levels=1:2
  435.     keys_zone=dg.fastcgi:500m
  436.     inactive=200000h
  437.     max_size=200G;
  438.  
  439. proxy_cache_path
  440.     /var/nginx_cache/proxy_cache
  441.     levels=1:2
  442.     keys_zone=dg.proxy:500m
  443.     inactive=200000h
  444.     max_size=200G;
  445.  
  446. # configuration file /etc/nginx/nginx_configs/gzip.conf:
  447.  
  448. # gzip
  449. gzip on;
  450. gzip_disable "msie6";
  451. gzip_comp_level 6;
  452. gzip_min_length 1100;
  453. gzip_buffers 16 8k;
  454. gzip_proxied any;
  455. gzip_types
  456.     text/plain
  457.     text/css
  458.     text/js
  459.     application/json
  460.     application/x-javascript
  461.     application/javascript
  462.     text/xml
  463.     application/xml
  464.     application/rss+xml
  465.     text/javascript
  466.     image/svg+xml
  467.     application/vnd.ms-fontobject
  468.     application/x-font-ttf
  469.     font/opentype;
  470.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement