-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.txt
103 lines (64 loc) · 1.95 KB
/
nginx.txt
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
=====
NGINX
=====
::
# check the config for syntax errors
sudo nginx -t
# reload nginx
sudo service nginx reload
NGINX installation
------------------
https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
NGINX config
------------
::
server {
# size of upload files
client_max_body_size 32m;
# 301 redirect
return 301 https://example.com$request_uri;
return 301 https://$host$request_uri;
}
NGINX SSL + auth_basic
----------------------
Add user/password for base auth::
sudo -v
echo "user:`openssl passwd -apr1`" | sudo tee -a /etc/nginx/htpasswd.users
Change the Nginx default server block ``/etc/nginx/sites-available/default``::
server {
listen 80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl default_server;
# Replace with your hostname
server_name elk.company.com;
ssl on;
# Certs have to exist
ssl_certificate /path/to/keys/cert.crt;
ssl_certificate_key /path/to/keys/key.key;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
NGINX log off
-------------
Off images access loging in access_log::
location ~* \.(gif|jpg|png) {
access_log off;
}
Change images access logimg location::
location ~* \.(gif|jpg|png)$ {
access_log /path/to/access.log;
}
Off access loging to dir and subdir::
location ^~ /images/ {
access_log off;
}