#0000 - Reorganize and enhance the NGINX configuration structure
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Introduce a refined NGINX configuration template with user, worker settings, and modular include directives. This improves clarity and allows easier integration of additional configuration files, while maintaining existing CORS settings.
This commit is contained in:
parent
6e94306755
commit
d15bf1c7d3
1 changed files with 34 additions and 23 deletions
57
nginx.conf
57
nginx.conf
|
@ -1,27 +1,38 @@
|
||||||
server {
|
user www-data;
|
||||||
listen 80;
|
worker_processes auto;
|
||||||
server_name yourdomain.com;
|
pid /run/nginx.pid;
|
||||||
|
include /etc/nginx/modules-enabled/*.conf;
|
||||||
|
|
||||||
location / {
|
events {
|
||||||
# other settings...
|
worker_connections 768;
|
||||||
|
}
|
||||||
|
|
||||||
# Allow CORS for all domains (or specify a particular domain instead of *)
|
http {
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name yourdomain.com;
|
||||||
|
|
||||||
# Allow specific headers
|
location / {
|
||||||
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
|
# other settings...
|
||||||
|
# Allow CORS for all domains (or specify a particular domain instead of *)
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
# Allow specific headers
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
|
||||||
|
# Allow specific methods
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
||||||
|
add_header 'Access-Control-Max-Age' 1728000;
|
||||||
|
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||||
|
add_header 'Content-Length' 0;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Allow specific methods
|
# Include other server and configuration files
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
include /etc/nginx/sites-enabled/*;
|
||||||
if ($request_method = 'OPTIONS') {
|
}
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
|
||||||
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';
|
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
|
|
||||||
add_header 'Access-Control-Max-Age' 1728000;
|
|
||||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
|
||||||
add_header 'Content-Length' 0;
|
|
||||||
return 204;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue