老谢博客

  • 首页
  • 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 回复
发表评论 点击取消评论.

*必填

*必填

  • 文章归档
  • 子网计算
  • 我的共享
  • 锻炼计划
  • 给我留言
  • 关于老谢
2025 年 5 月
一 二 三 四 五 六 日
 1234
567891011
12131415161718
19202122232425
262728293031  
« 4 月    

最新文章

  • 认知,是否是一座大山?当架构决策变成配置清单比价
  • 重装博客服务器环境
  • 特斯拉24款标续 Model Y 2万公里使用体验
  • 接盘的傻子
  • 小牛us电瓶指示灯闪三次不上电
  • 一次还不错的小米售后体验
  • 装台1600元办公主机
  • 2021好久没更新博客
  • Zabbix监控oxidized备份状态
  • Zabbix 5.0 LTS版本MySQL表分区及编译安装随记

最新评论

  • 老陳网志:有点高端,像我们整点nas玩玩就够...
  • springwood:自从 CentOS 不维护之后,我换 U...
  • 大D:难都搞下来了,那就更得YM了
  • 大D:只能是YM了,谢总牛啊
  • 灰常记忆:经济不好 今年我也换了机器 一...
  • 大峰:这是海外服务器嘛?速度挺快的。
  • 大D:只能单走一个6了哈哈哈
  • zwwooooo:买特斯拉和买iPhone的人群其实相似...
  • 平安家属子痕:一直坚持油车,看你写的心里有...
  • 秦大叔:室内每年能开2万公里电车确实划算 ...

日志存档

  • 2025 年 5 月
  • 2025 年 4 月
  • 2025 年 3 月
  • 2024 年 9 月
  • 2024 年 5 月
  • 2024 年 1 月
  • 2023 年 4 月
  • 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-2025 老谢博客 All rights reserved.
Gzipped 76.5% | Optimized loading 59 queries in 0.457 seconds | Memory 38.98 MB | 尼玛的备案
Powered by WordPress. | Hosted By LAOXUEHOST | Theme by WordPress主题巴士 | 站点地图 | SiteMap | uptime查询