nginx下solr安全 屏蔽外网访问 安全验证
nginx下solr安全 屏蔽外网访问 安全验证一、iptables进行设定指定端口访问:A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT#比如你的solr安装商品为8080,如果不是请自行修改为你自己的端口
二、nginx进行反向代理并且基础验证:
location /solr/ {
proxy_pass http://127.0.0.1:8983/solr/;
proxy_redirect default;
auth_basic "Restricted";
auth_basic_user_file "/usr/local/nginx/conf/solrAuth.conf";
}
三、下面是生成验证密码文件(/usr/local/nginx/conf/solrAuth.conf):
bash htpasswd.shhtpasswd.sh 中的内容为:#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo "====================================="
echo "# A tool like htpasswd for Nginx #"
echo "#-----------------------------------#"
echo "# Author:Licess http://www.lnmp.org #"
echo "====================================="
#set UserName
username=""
read -p "Please input UserName:" username
if [ "$username" = "" ]; then
echo "Error:UserName can't be NULL!"
exit 1
fi
echo "==========================="
echo "UserName was: $username"
echo "==========================="
#set password
unpassword=""
read -p "Please input the Password:" unpassword
if [ "$unpassword" = "" ]; then
echo "Error:Password can't be NULL!"
exit 1
fi
echo "==========================="
echo "Password was: $unpassword"
echo "==========================="
password=$(perl -e 'print crypt($ARGV, "pwdsalt")' $unpassword)
#set htpasswd file
htfile=""
read -p "Please input Auth filename:" htfile
if [ "$htfile" = "" ]; then
echo "Error:Auth filename can't be NULL!"
exit 1
fi
echo "==========================="
echo "Auth File: /usr/local/nginx/conf/$htfile"
echo "==========================="
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to Creat...or Press Ctrl+c to cancel"
char=`get_char`
if [ ! -f /usr/local/nginx/conf/$htfile.conf ]; then
echo "Create Auth file......"
cat >/usr/local/nginx/conf/$htfile.conf<<eof
$username:$password
eof
echo "Create Auth file successful,auth file path:/usr/local/nginx/conf/$htfile.conf."
else
echo "File already exists,please run this script again."
exit 1
finginx下solr安全 屏蔽外网访问 安全验证
页:
[1]