Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

配置 Nginx 整合各个组件

1.安装 Nginx
1)准备安装环境

1
yum install gcc-c++ libtool pcre-devel openssl-devel zlib-devel -y
2
useradd -d /home/nginx -M -s /sbin/nologin nginx
3
id nginx
4
uid=1001(nginx) gid=1001(nginx) groups=1001(nginx)

2)下载并安装Nginx

1
cd /usr/local/src/
2
wget http://nginx.org/download/nginx-1.15.10.tar.gz
3
tar xf nginx-1.15.10.tar.gz -C /usr/local/src/
4
cd /usr/local/src/nginx-1.15.10
5
6
./configure --prefix=/usr/local/nginx \
7
--sbin-path=/usr/local/nginx/sbin/nginx \
8
--conf-path=/usr/local/nginx/conf/nginx.conf \
9
--pid-path=/usr/local/nginx/logs/nginx.pid \
10
--error-log-path=/usr/local/nginx/logs/error.log \
11
--http-log-path=/usr/local/nginx/logs/access.log \
12
--with-pcre \
13
--user=nginx \
14
--group=nginx \
15
--with-file-aio \
16
--with-http_gzip_static_module \
17
--with-http_stub_status_module \
18
--with-http_v2_module \
19
--with-threads \
20
--with-http_realip_module \
21
--with-http_ssl_module
22
23
make && make install
24
echo $?
25
0

2.配置Nginx

1
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.default
2
vim /usr/local/nginx/conf/nginx.conf
3
#全局字段配置
4
user  nginx nginx;
5
worker_processes  auto;
6
error_log logs/error.log info;
7
pid logs/nginx.pid;
8
worker_rlimit_nofile 65535;
9
events {
10
    use epoll;
11
    worker_connections  65535;
12
    multi_accept on;
13
}
14
15
http {
16
    include       mime.types;
17
    default_type  application/octet-stream;
18
    charset utf-8;
19
    server_tokens off;
20
21
#定义Nginx缓存设置
22
    client_header_buffer_size 4096;
23
    large_client_header_buffers 4 128k;
24
    client_header_timeout 15;
25
    client_body_timeout 15;
26
    send_timeout 65;
27
    client_max_body_size 10m;
28
    open_file_cache max=65535 inactive=60s;
29
    open_file_cache_valid 30s;
30
    open_file_cache_min_uses 1;
31
    open_file_cache_errors on;
32
    server_names_hash_bucket_size 128;
33
 
34
#定义Nginx日志访问格式
35
   log_format  main  '$remote_addr" "$remote_user" "[$time_local]" "$request"'
36
                     ' "$status" "$body_bytes_sent" "$http_referer"'
37
                     ' "$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
38
                     ' "$upstream_addr" "$request_time" "$upstream_response_time" "$http_host"';
39
    access_log  logs/access.log  main;
40
41
#网络连接功能
42
    sendfile        on;
43
    autoindex       on;
44
    tcp_nopush      on;
45
    tcp_nodelay     on;
46
    keepalive_timeout  65;
47
    types_hash_max_size 2048;
48
    reset_timedout_connection on;
49
50
#压缩功能配置 
51
    gzip on;
52
    gzip_min_length 1k;
53
    gzip_buffers 16 64K;
54
    gzip_http_version 1.1;
55
    gzip_comp_level 6;
56
    gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
57
    gzip_vary on;
58
    gzip_proxied any;
59
    underscores_in_headers on;
60
    proxy_ignore_client_abort on;
61
62
    include /usr/local/nginx/conf/conf.d/*.conf;
63
}

3.创建 Nginx 文件并整合功能

1
mkdir /usr/local/nginx/conf/conf.d
2
vim /usr/local/nginx/conf/conf.d/jumpserver.conf
3
4
server {
5
    listen 80;
6
7
    client_max_body_size 100m;          # 录像及文件上传大小限制
8
9
    location /luna/ {
10
        try_files $uri / /index.html;
11
        alias /opt/luna/;               # luna 路径, 如果修改安装目录, 此处需要修改
12
    }
13
14
    location /media/ {
15
        add_header Content-Encoding gzip;
16
        root /opt/jumpserver/data/;     # 录像位置, 如果修改安装目录, 此处需要修改
17
    }
18
19
    location /static/ {
20
        root /opt/jumpserver/data/;     # 静态资源, 如果修改安装目录, 此处需要修改
21
    }
22
23
    location /socket.io/ {
24
        proxy_pass       http://localhost:5000/socket.io/;
25
        proxy_buffering off;
26
        proxy_http_version 1.1;
27
        proxy_set_header Upgrade $http_upgrade;
28
        proxy_set_header Connection "upgrade";
29
        proxy_set_header X-Real-IP $remote_addr;
30
        proxy_set_header Host $host;
31
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
32
        access_log off;
33
    }
34
35
    location /coco/ {
36
        proxy_pass       http://localhost:5000/coco/;
37
        proxy_buffering off;
38
        proxy_http_version 1.1;
39
        proxy_set_header Upgrade $http_upgrade;
40
        proxy_set_header Connection $http_connection;
41
        proxy_set_header X-Real-IP $remote_addr;
42
        proxy_set_header Host $host;
43
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
44
        access_log off;
45
    }
46
47
    location /guacamole/ {
48
        proxy_pass       http://localhost:8081/;
49
        proxy_buffering off;
50
        proxy_http_version 1.1;
51
        proxy_set_header Upgrade $http_upgrade;
52
        proxy_set_header Connection $http_connection;
53
        proxy_set_header X-Real-IP $remote_addr;
54
        proxy_set_header Host $host;
55
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
56
        access_log off;
57
    }
58
59
    location / {
60
        proxy_pass http://localhost:8080;
61
        proxy_set_header X-Real-IP $remote_addr;
62
        proxy_set_header Host $host;
63
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
64
    }
65
}

4.启动 检查并启动Nginx

1
/usr/local/nginx/sbin/nginx -t
2
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
3
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
4
5
/usr/local/nginx/sbin/nginx
Weiliang Xu wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
-------------    本文结束  感谢您的阅读    -------------