-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx_default.conf
74 lines (62 loc) · 2.09 KB
/
nginx_default.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Default server definition
server {
# Listen on port 80 for both IPv4 and IPv6
listen [::]:80;
listen 80;
server_name $host;
# Log files for access and errors
access_log /var/log/nginx/nagios_access.log;
error_log /var/log/nginx/nagios_error.log;
# Document root for Nagios
root /usr/local/nagios/share;
auth_basic "Nagios Access";
auth_basic_user_file /usr/local/nagios/etc/htpasswd.users;
# Default location to serve PHP and HTML files
location / {
index index.php index.html index.htm;
}
# Error pages redirection
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# PHP processing with PHP-FPM
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user; # Add this line
}
# Serving Nagios CGI scripts from /usr/local/nagios/sbin
location ~ \.cgi$ {
root /usr/local/nagios/sbin;
rewrite ^/nagios/cgi-bin/(.*) /$1 break;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
include fastcgi_params;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
# Caching static assets for 5 days
location ~* \.(jpg|jpeg|png|gif|css|js|ico|xml)$ {
rewrite ^/nagios/(.*) /$1 break;
expires 5d;
add_header Cache-Control "public, no-transform";
}
# Deny access to hidden files
location ~ /\. {
log_not_found off;
deny all;
}
# Allow FPM status and ping only from localhost
location ~ ^/(fpm-status|fpm-ping)$ {
access_log off;
allow 127.0.0.1;
deny all;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.sock;
}
}