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