影落离风

The shadow falls away from the wind

0%

nginx反向代理和配置密码访问

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
102
103
104
105
106
107
108
109
110
111
user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
# 问题:excel导出超时可配置
# 请求存活时间
keepalive_timeout 65; #秒
# 后端服务器处理请求的时间设置(页面等待服务器响应时间)
proxy_read_timeout 150; # 秒

#types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

server {
listen 8001;
server_name localhost 127.0.0.1;
#允许通过请求后缀
location ~.*\.(gif|jpg|jpeg|png|html|css|js|ico|ttf|woff|xlsx|mp3|pcm|mp4|php|py|xls|xlsx|doc|docx|txt)$ {
expires 24h;
root /home/gas/html/;#指定图片存放路径
index index.html index.htm index.php; # 首页匹配

}
}

server {
listen 80;
server_name localhost 127.0.0.1;
location ~.*\.(gif|jpg|jpeg|png|html|css|js|ico|ttf|woff|xlsx|mp3|pcm|mp4|php|py|xls|xlsx|doc|docx|txt)$ {
expires 24h;
root /home/gas/html/;#指定图片存放路径
index index.html index.htm index.php; # 首页匹配

}
#反向代理端口,访问 127.0.0.1/api/
location /api/ {
proxy_pass http://192.168.7.19:8077/;
client_max_body_size 10m;
}

#反向代理端口,访问 127.0.0.1/hle/
location /hle/ {
proxy_pass http://192.168.7.19:8077/;
client_max_body_size 10m;
}

#访问输密码验证
location / {
proxy_pass http://192.168.7.19:5601$request_uri;
client_max_body_size 10m;
auth_basic "登陆验证";
auth_basic_user_file /etc/nginx/htpasswd; #/etc/nginx/htpasswd是密码文件,路径自定义
}


}

include /etc/nginx/conf.d/*.conf;
}