老谢博客

  • 首页
  • WordPress
  • 网络技术
  • 乱七八糟
  • 运维技术
  • 给我留言
  • 关于老谢

laoxie.me

分类:网站技术日期:2018-11-08 - 19:53:25作者:老谢

  不知不觉都写8年博客了,xj123.info也注册8年了,唉唉唉,最开始.tk的域名以及写了小半年的ZBLOG的日志,你敢信当时.tk的域名我都备案成功了!?换WordPress的时候数据丢真是可惜 T_T 很想知道当时写了什么23333,当时图便宜注册个.info也是醉了,后来各种原因包括换到阿里云以后更是因为备案问题懒得为了换域名折腾,拖拖拖一拖又是好几年(擦!都换到阿里云4年了),最近手痒顺手查查laoxie.me居然已经过期释放了,妥妥注册过来(本来想啥时候注册到laoxie.com啥时候再换,但估计是等不到了,确认过眼神是买不起的.com双拼…),就想着把域名用上,其实也不算换域名,旧域名依然会保持访问也不会做跳转,只是用laoxie.me做个反代,以后结识新朋友都会以laoxie.me留言啦!

  趁着光棍节活动,新购入了一台香港阿里云ECS作为反代使用(后悔了,应该直接买3年,平均每年300块,现在只买了1年,按照阿里云的尿性续费肯定没优惠,到时候估计得新购换IP…),为了换域名也是拼了,新域名懒得备案,只能想到反代这招了…ECS异地居然还不能走内网通信,蛋疼蛋疼,现在的阿里云默认都是开了端口策略,只开放了些许端口,甚至80和443这样的端口默认都没被允许入站,懒得新创建入站规则,所以SSH端口就用默认了22了,但毕竟暴露在公网,还是稍稍做些防护会好些),之前也有过相关的帖子:谁偷走了我的密码?,IP归属地分析Shell脚本。

安全设置,防暴力破解ssh
vim /root/secure_ssh/secure_ssh.sh
 
#! /bin/bash
cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/secure_ssh/black.list
for i in `cat  /root/secure_ssh/black.list`
do
  IP=`echo $i |awk -F= '{print $1}'`
  NUM=`echo $i|awk -F= '{print $2}'`
  if [ ${#NUM} -gt 1 ]; then
    grep $IP /etc/hosts.deny > /dev/null
    if [ $? -gt 0 ];then
      echo "sshd:$IP:deny" >> /etc/hosts.deny
    fi
  fi
done
 
#从这些行中提取IP地址,如果次数达到10次(脚本中判断次数字符长度是否大于1)则将该IP写到 /etc/hosts.deny中。
 
#将secure_ssh.sh脚本放入cron计划任务,每1分钟执行一次。
*/1 * * * *  sh /root/secure_ssh/secure_ssh.sh

vim /root/secure_ssh/secure_ssh.sh #! /bin/bash cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /root/secure_ssh/black.list for i in `cat /root/secure_ssh/black.list` do IP=`echo $i |awk -F= '{print $1}'` NUM=`echo $i|awk -F= '{print $2}'` if [ ${#NUM} -gt 1 ]; then grep $IP /etc/hosts.deny > /dev/null if [ $? -gt 0 ];then echo "sshd:$IP:deny" >> /etc/hosts.deny fi fi done #从这些行中提取IP地址,如果次数达到10次(脚本中判断次数字符长度是否大于1)则将该IP写到 /etc/hosts.deny中。 #将secure_ssh.sh脚本放入cron计划任务,每1分钟执行一次。 */1 * * * * sh /root/secure_ssh/secure_ssh.sh

  至此脚本将每分钟爬一遍/var/log/secure找到登录失败超过3次的ip丢进/etc/hosts.deny,其实更想用iptables来操作,比如配个csf,但是想想好麻烦…再说吧再说吧…..在配置的过程中发/etc/log/secure没有日志,重启sshd和rsyslog以后还是没有新日志,经过一番搜索,将sshd_config的日志级别调整为SyslogFacility AUTHPRIV,然后重启sshd即可正常生成日志!

  天下文章一大抄,我抄自:https://cloud.tencent.com/developer/article/1119081

Nginx1.9.9 编译安装
./configure --prefix=/usr/local/nginx \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_ssl_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-mail --with-mail_ssl_module \
--with-pcre=../pcre-8.30 \
--with-zlib=../zlib-1.2.11 \
--with-debug \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-http_sub_module

./configure --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --with-http_ssl_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_realip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-mail --with-mail_ssl_module \ --with-pcre=../pcre-8.30 \ --with-zlib=../zlib-1.2.11 \ --with-debug \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --with-http_sub_module

  pcre和zlib自行找下安装包,解压后路径填对即可,反代需要用到http_sub_module模块,必须编译进去!其他可以参考本站:CentOS编译安装Nginx(附:管理脚本)

Nginx反代配置
server {
    listen 80;
    server_name laoxie.me;#反代域名
    #这里的跳转,如果不是要反代ssl网站就不用了
        if ( $scheme = http ){
		return 301 https://$server_name$request_uri;
	}
 
	#屏蔽蜘蛛,防止降权,反代别人的网站。。。就随便了
	#if ($http_user_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) {
	#	return  403;
	#	}
 
	#反代规则设置
	location / {
	sub_filter laoxie.me laoxie.me; #网站域名,反代域名
	sub_filter_once off;#进行替换
	proxy_cache cache_one;
        #缓存区名称
        proxy_cache_valid  200 304 3h;
        #200 304状态缓存3小时
        proxy_cache_valid 301 3d;
        #301状态缓存3天
        proxy_cache_valid any 10s;
        #其他状态缓存(如502 404)10秒
        proxy_cache_key "$scheme://$host$request_uri";
        #缓存key规则,自动清除缓存
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	#向后端传递访客ip
	proxy_set_header Referer http://laoxie.me;
        #强制定义Referer
	proxy_set_header Host laoxie.me;
	#定义主机
	proxy_pass http://laoxie.me;
	#
	proxy_set_header Accept-Encoding "";
	#重要 将信息传递到服务器端
		}
 
}
 
server
	{
	listen 443 ssl;
	ssl on;
        ssl_certificate /usr/local/nginx/conf/ssl/laoxie_me.crt;
        ssl_certificate_key /usr/local/nginx/conf/ssl/laoxie.me.key;
        #这里的域名证书是你反代的域名的证书,现在免费证书网上一大堆可以申请的,就不说了
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
        ssl_prefer_server_ciphers on;
        ssl_session_timeout 10m;
        ssl_session_cache builtin:1000 shared:SSL:10m;
        ssl_buffer_size 1400;
        add_header Strict-Transport-Security max-age=15768000;
	#ssl_trusted_certificate /usr/local/nginx/conf/ssl/laoxie_me.crt;
        #ssl_stapling on;
        #ssl_stapling_verify on;
	#resolver 8.8.8.8 8.8.4.4 valid=300s;
	#resolver_timeout 5s;
 
        #跳转https
	#if ( $scheme = http ){
	#	return 301 https://$server_name$request_uri;
	#	}
 
	#屏蔽蜘蛛,防止降权
	#if ($http_user_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) {
	#	return  403;
	#	}
 
        #反代规则设置
	location / {
	sub_filter laoxie.me laoxie.me; #网站域名,反代域名
	sub_filter_once off;
	proxy_cache cache_one;
        #缓存区名称
        proxy_cache_valid  200 304 3h;
        #200 304状态缓存3小时
        proxy_cache_valid 301 3d;
        #301状态缓存3天
        proxy_cache_valid any 10s;
        #其他状态缓存(如502 404)10秒
        proxy_cache_key "$scheme://$host$request_uri";
        #缓存key规则,自动清除缓存
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	#向后端传递访客ip
	proxy_set_header Referer https://laoxie.me;
        #强制定义Referer
	proxy_set_header Host laoxie.me;
	#定义主机
	proxy_pass_header Set-Cookie;
        #这两句是为了实现wordpress的正常功能
        #proxy_cache_bypass $logged_in;
        #proxy_no_cache $logged_in;
        #这两句是为了实现wordpress的正常功能
	proxy_pass https://laoxie.me;
	#这种写法,这里就必须得是https
	proxy_set_header Accept-Encoding "";
	#重要将信息传递到服务器端
	}
}

server { listen 80; server_name laoxie.me;#反代域名 #这里的跳转,如果不是要反代ssl网站就不用了 if ( $scheme = http ){ return 301 https://$server_name$request_uri; } #屏蔽蜘蛛,防止降权,反代别人的网站。。。就随便了 #if ($http_user_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) { # return 403; # } #反代规则设置 location / { sub_filter laoxie.me laoxie.me; #网站域名,反代域名 sub_filter_once off;#进行替换 proxy_cache cache_one; #缓存区名称 proxy_cache_valid 200 304 3h; #200 304状态缓存3小时 proxy_cache_valid 301 3d; #301状态缓存3天 proxy_cache_valid any 10s; #其他状态缓存(如502 404)10秒 proxy_cache_key "$scheme://$host$request_uri"; #缓存key规则,自动清除缓存 proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #向后端传递访客ip proxy_set_header Referer http://laoxie.me; #强制定义Referer proxy_set_header Host laoxie.me; #定义主机 proxy_pass http://laoxie.me; # proxy_set_header Accept-Encoding ""; #重要 将信息传递到服务器端 } } server { listen 443 ssl; ssl on; ssl_certificate /usr/local/nginx/conf/ssl/laoxie_me.crt; ssl_certificate_key /usr/local/nginx/conf/ssl/laoxie.me.key; #这里的域名证书是你反代的域名的证书,现在免费证书网上一大堆可以申请的,就不说了 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_timeout 10m; ssl_session_cache builtin:1000 shared:SSL:10m; ssl_buffer_size 1400; add_header Strict-Transport-Security max-age=15768000; #ssl_trusted_certificate /usr/local/nginx/conf/ssl/laoxie_me.crt; #ssl_stapling on; #ssl_stapling_verify on; #resolver 8.8.8.8 8.8.4.4 valid=300s; #resolver_timeout 5s; #跳转https #if ( $scheme = http ){ # return 301 https://$server_name$request_uri; # } #屏蔽蜘蛛,防止降权 #if ($http_user_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) { # return 403; # } #反代规则设置 location / { sub_filter laoxie.me laoxie.me; #网站域名,反代域名 sub_filter_once off; proxy_cache cache_one; #缓存区名称 proxy_cache_valid 200 304 3h; #200 304状态缓存3小时 proxy_cache_valid 301 3d; #301状态缓存3天 proxy_cache_valid any 10s; #其他状态缓存(如502 404)10秒 proxy_cache_key "$scheme://$host$request_uri"; #缓存key规则,自动清除缓存 proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #向后端传递访客ip proxy_set_header Referer https://laoxie.me; #强制定义Referer proxy_set_header Host laoxie.me; #定义主机 proxy_pass_header Set-Cookie; #这两句是为了实现wordpress的正常功能 #proxy_cache_bypass $logged_in; #proxy_no_cache $logged_in; #这两句是为了实现wordpress的正常功能 proxy_pass https://laoxie.me; #这种写法,这里就必须得是https proxy_set_header Accept-Encoding ""; #重要将信息传递到服务器端 } }

  ssl_stapling的配置还没搞懂,反正开了以后nginx -t报错,暂时先关了,有时间再折腾吧…以上抄自:https://cloud.tencent.com/developer/article/1050221

我还是忍不住做rewrite了

  对,是的,现在访问xj123.info已经rewrite到了laoxie.me,懒得搞主要是嫌麻烦,突然今天想到可以根据$remote_addr来做rewrite,只要不是反代的ip发起的请求都rewrite到laoxie.me:

                if  ( $remote_addr != '反代服务器ip'  )  {
                  rewrite ^/(.*)$ https://laoxie.me/$1 permanent;
                }

if ( $remote_addr != '反代服务器ip' ) { rewrite ^/(.*)$ https://laoxie.me/$1 permanent; }

原文地址 : https://www.xj123.info/7337.html

本站遵循 : 署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5)

版权声明 : 原创文章转载时,请务必以超链接形式标明文章原始出处

  • 上一篇:Bind9+NamedManager构建高可用DNS服务器
  • 下一篇:修复Surface Pro 4幽灵触摸故障
30条评论
  1. 演员 说:

    我服务器被暴力破解过!-.- 我就加了https 错误证书! 社会不!

    POST:2018-11-08 20:18 回复
    • 老谢 说:

      暴力破解和https有什么关系?

      POST:2018-11-08 22:06 回复
  2. faw.life 说:

    换吧 现在这个域名太没个性

    POST:2018-11-09 12:27 回复
    • 老谢 说:

      真正换域名要做的工作太多,包括通知友链更新blalalaa,太麻烦了……

      POST:2018-11-09 13:29 回复
  3. Han 说:

    之前我也见过一个用着tk域名的博客,成功备案,还在群里炫耀,哈哈。

    POST:2018-11-13 13:24 回复
    • 老谢 说:

      现在已经没人用.tk了吧

      POST:2018-11-13 22:27 回复
  4. adamfei 说:

    一段时间没来,更新的速度……666

    POST:2018-11-13 18:31 回复
    • 老谢 说:

      哈哈哈 你也是匿好久了…

      POST:2018-11-13 22:27 回复
  5. 不给力的面条 说:

    防暴力破解统一使用 fail2ban 就行

    POST:2018-11-16 14:31 回复
    • 老谢 说:

      搜了下Fail2Ban很强大,折腾中~

      POST:2018-11-19 15:13 回复
  6. 山小炮 说:

    我08年左右开始玩网站的,记得那时候tk可以免费一年,当时还注册了几个tk域名。

    POST:2018-11-19 09:13 回复
    • 老谢 说:

      老站长~我记得我最早注册的域名是1块钱1年的.CN,tk好像有个政策几个月不用就会回收

      POST:2018-11-19 15:14 回复
    • 子痕 说:

      我做网站早,不过自己的博客从06年开始,比你早2年。

      POST:2018-11-23 19:39 回复
  7. kn007 说:

    1.9.9!?
    我的天

    POST:2018-11-20 18:48 回复
    • 老谢 说:

      哈哈,我也觉得更新的有点快 …

      POST:2018-11-20 20:56 回复
      • kn007 说:

        我意思版本不够新

        POST:2018-11-20 21:00 回复
        • 老谢 说:

          我就不说 .. 我的博客还在用1.13.3 …

          POST:2018-11-20 21:03 回复
        • 老谢 说:

          咦!是啊,怎么才1.9.9,我找个新点的版本换上……

          POST:2018-11-20 21:05 回复
          • kn007 说:

            用HTTP2,不更新会被打爆的。最新的修复了个漏洞

            POST:2018-11-20 21:07 回复
        • 老谢 说:

          我知道了,nginx的download列目录不是按时间排序的,我直接找的往后的下载,以为是最新的………………

          POST:2018-11-20 21:07 回复
          • kn007 说:

            …………………………………………….好吧

            POST:2018-11-20 21:09 回复
            • 老谢 说:

              更到1.15.5了,感谢感谢~~~我都没注意,哈哈哈哈哈

              POST:2018-11-20 21:10 回复
              • kn007 说:

                打PP

                POST:2018-11-20 21:11 回复
  8. 旧日的足迹 说:

    我记得你,我也用过TK域名一段时间..

    POST:2018-11-21 15:21 回复
    • 老谢 说:

      用过TK的大概都是老站长了,哈哈

      POST:2018-11-22 22:44 回复
  9. gongyi 说:

    laoxie.me 这个挺好记的啊! 我的个人博客就是用的我自己名字的拼音,后缀虽然不好用的info,我也觉得凑合用就行!

    POST:2018-11-22 23:20 回复
    • 老谢 说:

      反正没多少人访问,自己玩的开心最重要

      POST:2018-11-23 23:18 回复
  10. 子痕 说:

    不太明白反代是什么意思

    POST:2018-11-23 19:39 回复
    • 老谢 说:

      就是反向代理

      POST:2018-11-23 23:19 回复
  11. 成考报名时间 说:

    那今年就是第十年了

    POST:2020-10-17 11:19 回复
发表评论 点击取消评论.

*必填

*必填

  • 文章归档
  • 子网计算
  • 我的共享
  • 锻炼计划
  • 给我留言
  • 关于老谢
2023年 4月
一 二 三 四 五 六 日
 12
3456789
10111213141516
17181920212223
24252627282930
« 10月    

最新文章

  • 2021好久没更新博客
  • Zabbix监控oxidized备份状态
  • Zabbix 5.0 LTS版本MySQL表分区及编译安装随记
  • centos7.9部署oxidized自动备份交换机配置
  • Surface Pro 4更换屏幕与电池
  • VCSA中删除horizon view链接克隆生成的replica-受保护副本
  • Esxi6.7U3安装SanDisk Fusion-io 1.3T ioscale Pci SSD加速卡驱动
  • 搭建ELK日志系统分析处理fortigate的syslog日志
  • 华为USG防火墙配置NAT映射回流解决内网通过公网映射访问内部服务器
  • 飞塔防火墙fortitoken配置

最新评论

  • 无敌风火轮:和索尼没啥关系,这是索尼电脑的...
  • zhudong:老大,有VMware Horizon 7.12相关资...
  • qx:所有连接失效了,求一份
  • RainH:大佬,这个111.111.111.111是什么鬼?...
  • 王叨叨:幸福的人都是相似的,不幸的人各有各...
  • 李海博客:李海博客前来学习!
  • 明月登楼:最近使用了ZeroSSL证书,感觉还不...
  • 鸟叔:尽管不知道干啥的,还是来顶一下
  • 鸟叔:鸟叔来贵博客参观学习,通过十年之约穿...
  • 周良粥凉:往前看。

日志存档

  • 2021年10月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2020年11月
  • 2020年9月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年1月
  • 2019年12月
  • 2019年10月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年3月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年1月
  • 2017年10月
  • 2017年9月
  • 2017年8月
  • 2017年7月
  • 2017年2月
  • 2017年1月
  • 2016年12月
  • 2016年11月
  • 2016年10月
  • 2016年7月
  • 2016年6月
  • 2016年4月
  • 2016年2月
  • 2016年1月
  • 2015年12月
  • 2015年10月
  • 2015年9月
  • 2015年7月
  • 2015年5月
  • 2015年4月
  • 2015年3月
  • 2015年2月
  • 2015年1月
  • 2014年12月
  • 2014年10月
  • 2014年9月
  • 2014年8月
  • 2014年7月
  • 2014年6月
  • 2014年5月
  • 2014年4月
  • 2014年3月
  • 2014年2月
  • 2014年1月
  • 2013年12月
  • 2013年11月
  • 2013年10月
  • 2013年9月
  • 2013年8月
  • 2013年7月
  • 2013年6月
  • 2013年5月
  • 2013年4月
  • 2013年3月
  • 2013年2月
  • 2013年1月
  • 2012年12月
  • 2012年11月
  • 2012年9月
  • 2012年8月
  • 2012年7月
  • 2012年6月
  • 2012年5月
  • 2012年4月
  • 2012年3月
  • 2012年2月
  • 2012年1月
  • 2011年12月
  • 2011年11月
  • 2011年10月
  • 2011年9月
  • 2011年8月
  • 2011年7月
  • 2011年6月
  • 2011年5月
  • 2011年4月
  • 2011年3月
  • 2011年2月
  • 2011年1月
  • 2010年12月
  • 2010年11月
  • 2010年10月
  • 2010年9月
  • 2010年8月
  • 2010年7月

W3C

  • XHTML 1.0 Transitional
  • CSS level 3
  • Google+
Copyright © 2010-2023 老谢博客 All rights reserved.
Gzipped 76.5% | Optimized loading 70 queries in 0.287 seconds | Memory 33.65 MB | 皖ICP备13010663号-1
Powered by WordPress. | Hosted By 腾讯云 | Theme by WordPress主题巴士 | 站点地图 | SiteMap | Uptime | 技术支持:苏州天剑计算机系统有限公司