nginx

nginx-v1.15.12

生產環境安裝

1、首先檢查依賴,yum install gcc-c++
2、下載以下幾個tar
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
3、我們生產只需要prce即可,上述安裝./configure --prefix=/opt/software && make && make install 即可
4、下載wget http://nginx.org/download/nginx-1.10.2.tar.gz 
解壓 進入./configure --prefix=/opt/software --with-pcre=/usr/local/pcre-8.35 && make && make install
--with-pcre這裏的路徑寫的是pcre的源碼的路徑
5、如果啓動報錯error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解決方法:ln -s /usr/local/lib/libpcre.so.1 /lib64
如果不是root,只能使用1024以上的端口

 

1、配置初始頁面,在es下創建index.html
  

 server {
        listen       8090;
        server_name  es.taikang.com;
        # 網站根目錄
        root   html/es;
        location / {           
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }


es.taikang.com:8090 訪問自己寫的index.html

如果這樣訪問不到,需要 ./nginx  -s  reload,重啓可能不好使,需要重新讀取配置文件。 

2、打開配置文件,文件裏面有http{},http{}中有server{},
增加一個網站虛擬機就是增加個server
    

    upstream es{
        # ip_hash
        server 127.0.0.1:9200 weight=1 max_fails=3 fail_timeout=20s;
        server 127.0.0.1:5601 weight=1 max_fails=3 fail_timeout=20s;
    }
    
    server {
        listen       8090;
        server_name  es.taikang.com;
        location / {
            proxy_pass http://es;
        }
    }

ip_hash,解決是session丟失問題,使一個用戶訪問的是同一個服務器。

3、配置hosts,哪臺機器訪問就配置哪臺, es.taikang.com ,訪問es.taikang.com+端口號,就能訪問到了

curl   es.taikang.com:8090

4、常用命令

啓動: ./nginx 

停止: ./nginx -s stop

重啓 :./nginx -s reopen

重載配置文件: ./nginx -s reload

幫助: ./nginx -h

檢查配置文件: ./nginx -t

 

 

Kibana採用nginx做登陸認證
背景
kibana默認是沒有用戶名密碼的,想用官方的認證,x-pack,收費的

方案:用nginx的代理功能做登陸認證
安裝nginx(略)
安裝Apache密碼生產工具: yum install httpd-tools
生成密碼文件:

mkdir -p /usr/local/test/passwd
cd /usr/local/test/passwd

執行命令

htpasswd -c -b kibana.passwd admin admin

編輯nginx配置文件nginx.conf:

    server {
        listen       8090;
        server_name  kibana;

        location / {
            auth_basic "kibana login auth";
            auth_basic_user_file /usr/local/test/passwd/kibana.passwd;
            proxy_pass http://192.168.88.131:5601;
            proxy_redirect off;
        }
    }


配置本地hosts文件: 192.168.88.131  kibana
啓動nginx和kibana,訪問http://kibana:8090,彈框提示輸入用戶名和密碼(用戶名:admin密碼:admin)
--------------------- 
原文:https://blog.csdn.net/dwyane__wade/article/details/80190771 
 

 

 

發佈了44 篇原創文章 · 獲贊 5 · 訪問量 2612
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章