Files
eletter/_docker/nginx/app.conf
2024-07-19 11:13:43 +07:00

82 lines
3.3 KiB
Plaintext

server {
listen 80 default_server;
index index.php index.html;
root /app;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# set client body size#
client_max_body_size 8M;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
# include snippets/fastcgi-php.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffers 4 4096k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 3000s;
fastcgi_send_timeout 3000s;
fastcgi_read_timeout 3000s;
}
# try_files $uri $uri/ /index.php;
# if (!-e $request_filename){
# rewrite ^/admin/(.*)$ /admin/index.php?/$1? last;
# rewrite ^/api/(.*)$ /api/index.php?/$1? last;
# rewrite ^/(.*)$ /index.php?/$1? last;
# }
location ~* \.(jpe?g|gif|png|bmp|ico|pdf|zip|htm|html|docx?|xlsx?|pptx?|txt|wav|swf|avi|mp\d)$ {
access_log off;
log_not_found off;
try_files $uri $uri/ $document_root$uri /index.php?$args;
expires 1w;
}
location ~ /\. {
access_log denied;
log_not_found off;
deny all;
}
}