server { listen 80; server_name api.sundayenglish.com; index index.php index.html; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; add_header Access-Control-Allow-Origin *; underscores_in_headers on; root /var/www; location /.well-known/acme-challenge/ { root /var/www/certbot; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass api-service-php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; # Định nghĩa fastcgi_cache_key # fastcgi_cache_key "$scheme$request_method$host$request_uri"; # Định nghĩa fastcgi_cache # fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=FASTCGI_CACHE:10m inactive=60m use_temp_path=off; #cache settings # fastcgi_cache FASTCGI_CACHE; # fastcgi_cache_valid 200 301 302 10m; # fastcgi_cache_valid 404 1m; # fastcgi_cache_bypass $http_cookie; # fastcgi_no_cache $http_cookie; # fastcgi_buffer_size 16k; # fastcgi_buffers 4 16k; # fastcgi_busy_buffers_size 32k; # fastcgi_temp_file_write_size 32k; } location / { try_files $uri $uri/ /index.php$is_args$args; gzip_static on; proxy_buffering on; proxy_buffers 8 160k; proxy_buffer_size 320k; proxy_busy_buffers_size 640k; } location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|otf)$ { expires 30d; access_log off; } client_max_body_size 1024m; } # server { # listen 443 ssl http2; # # ssl on; # # add_header Access-Control-Allow-Origin *; # # add_header Access-Control-Allow-Headers "*"; # # add_header Access-Control-Allow-Methods "GET,POST,OPTIONS,DELETE,PUT"; # add_header 'Access-Control-Allow-Origin' "*" always; # add_header 'Access-Control-Allow-Credentials' 'true' always; # add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; # add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,X-API-KEY,jwt_token' always; # # required to be able to read Authorization header in frontend # add_header 'Access-Control-Expose-Headers' 'Authorization' always; # server_name api.sundayenglish.com; # index index.php index.html; # error_log /var/log/nginx/error.log; # access_log /var/log/nginx/access.log; # underscores_in_headers on; # root /var/www; # ssl_certificate /etc/nginx/ssl/live/api.sundayenglish.com/fullchain.pem; # ssl_certificate_key /etc/nginx/ssl/live/api.sundayenglish.com/privkey.pem; # # optimiz SSL settings # ssl_session_cache shared:SSL:10m; # ssl_session_timeout 1h; # ssl_prefer_server_ciphers on; # ssl_protocols TLSv1.2 TLSv1.3; # ssl_ciphers HIGH:!aNULL:!MD5; # # ssl_dhparam /etc/nginx/ssl/dhparam.pem; # location ~ \.php$ { # try_files $uri =404; # fastcgi_split_path_info ^(.+\.php)(/.+)$; # fastcgi_pass api-service-php:9000; # fastcgi_index index.php; # include fastcgi_params; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_param PATH_INFO $fastcgi_path_info; # # fastcgi_cache FASTCGI_CACHE; # # fastcgi_cache_valid 200 301 302 10m; # # fastcgi_cache_valid 404 1m; # # fastcgi_cache_bypass $http_cookie; # # fastcgi_no_cache $http_cookie; # # fastcgi_buffer_size 16k; # # fastcgi_buffers 4 16k; # # fastcgi_busy_buffers_size 32k; # # fastcgi_temp_file_write_size 32k; # } # location / { # if ($request_method = 'OPTIONS' ) { # return 204 no-content; # } # try_files $uri $uri/ /index.php$is_args$args; # gzip_static on; # proxy_buffering on; # proxy_buffers 8 160k; # proxy_buffer_size 320k; # proxy_busy_buffers_size 640k; # } # location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|otf)$ { # expires 30d; # access_log off; # } # client_max_body_size 1024m; # }