中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Nginx 部署和配置

發布時間:2020-06-13 13:17:46 來源:網絡 閱讀:251 作者:紅塵世間 欄目:系統運維
1. 安裝
[root@localhost ~]# yum -y install gcc wget pcre-devel openssl-devel
# sticky 第三方擴展的模塊用于 session 綁定, 比 nginx 默認實現的 session 綁定模塊更加強大
[root@localhost ~]# wget https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/master.tar.gz
[root@localhost ~]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
[root@localhost ~]# tar xvf nginx-1.14.2.tar.gz 
[root@localhost ~]# tar xvf master.tar.gz
[root@localhost ~]# cd nginx-1.14.2
[root@localhost ~]# ./configure --prefix=/opt/nginx-1.14.2 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module \
--add-module=../nginx-goodies-nginx-sticky-module-ng-08a395c66e42/
[root@localhost ~]# make -j $(cat /proc/cpuinfo | grep -c processor) && make install
[root@localhost ~]# ln -s /opt/nginx-1.14.2/ /opt/nginx
[root@localhost ~]# echo 'PATH=${PATH}:/opt/nginx/sbin/' > /etc/profile.d/nginx.sh
[root@localhost ~]# useradd -M -s /sbin/nologin nginx
2. 配置
user  nginx;
worker_processes  6;
worker_cpu_affinity 000001 000010 000100 001000 010000 100000;

pid        logs/nginx.pid;

events {
    worker_connections  10240;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    server_names_hash_bucket_size 512;
    server_names_hash_max_size 512 ;

    log_format  main  '$http_x_real_ip $remote_addr $http_host - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';

    sendfile        on;
    keepalive_timeout  120;

    client_max_body_size 15m;

    proxy_store off;
    proxy_redirect off;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $http_x_real_ip;
    proxy_set_header Host $http_host;
    proxy_connect_timeout 120;
    proxy_read_timeout 120;
    proxy_send_timeout 120;

    upstream test {
        sticky expires=30d name=test1;
        server 192.168.1.1:80;
        server 192.168.1.2:80;
        server 192.168.1.3:80;
    }

    # 強制 http 跳轉到 https
    # if ($server_port = 80) {
    #     return 301 https://$host$request_uri;
    # }

    server {
        listen       80;
        server_name  http.test.com;

        access_log  logs/access.log  main;

        location / {
            proxy_pass    https://test;
        }
    }

    server {
        listen       443 ssl;
        server_name  https.test.com;

        access_log  logs/access.log  main;

        ssl_certificate "/PATH/xxxxx.crt";
        ssl_certificate_key "/PATH/xxxxx.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        location / {
            proxy_pass    https://test;
        }
    }
}
3. 創建 UnitFile 文件
[root@localhost ~]# cat > /usr/lib/systemd/system/nginx.service << EOF
[unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl start nginx
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

华容县| 丰县| 鹤岗市| 汪清县| 衡山县| 庆云县| 娄底市| 凌海市| 思茅市| 宝应县| 乌鲁木齐市| 龙山县| 鸡东县| 湘潭县| 河东区| 明溪县| 迭部县| 定州市| 仙居县| 福泉市| 台北县| 吉林市| 榆树市| 海伦市| 龙井市| 大姚县| 稻城县| 会理县| 龙门县| 阳西县| 宝丰县| 连云港市| 安泽县| 滦平县| 达日县| 普格县| 汉川市| 永和县| 城口县| 永嘉县| 丹寨县|