Nov 17

HTTP自动转向HTTPS

Apache 版本

如果需要整站跳转,则在网站的配置文件的<Directory>标签内,键入以下内容:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R=301]


如果对某个目录做https强制跳转,则复制以下代码:

RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]


Nginx版本

在配置80端口的文件里面,写入以下内容即可。

server {
        listen       80;
        server_name  localhost;
        rewrite ^(.*)$ https://$host$1 permanent;    
}



阅读全文...

Nov 15

mount samba share folder in Ubuntu

sudo mount -t cifs -o  username=xxx,password=xxx,iocharset=utf8,dir_mode=0777,file_mode=0777 //192.168.1.1/abc   /home/xyz/abc

阅读全文...

Nov 15

Aira2

阅读全文...

Nov 14

clash for Linux as system service

Download and unzip package from following URL

https://github.com/Dreamacro/clash

Execute the clash once and it generated the .config folder under /home/<user> path

Automactically download initial config.yaml & country.mmdb from web.

Download the config.yaml from the ladder site and replace the original config file.

Create clash.service file as following

# edit and save this file to /usr/lib/systemd/system/clash.service
[Unit]
Description=clash
After=network.target
[Service]
WorkingDirectory=/home/<usrid>/.config/clash
ExecStart= /home/<usrid>/.config/clash/start-clash.sh
ExecStop= /home/<usrid>/.config/clash/stop-clash.sh
Environment="HOME=/home/<usrid>"
#Environment="CLASH_URL="
[Install]
WantedBy=multi-user.target


Create two shell scripts:

#!/bin/bash
# save this file to ${HOME}/.config/clash/start-clash.sh
# save pid file
echo $$ > ${HOME}/.config/clash/clash.pid
${HOME}/work/clash
#!/bin/bash
# save this file to ${HOME}/.config/clash/stop-clash.sh
# read pid file
PID=`cat ${HOME}/.config/clash/clash.pid`
kill -9 ${PID}
rm ${HOME}/.config/clash/clash.pid

Then enable and start clash as service

systemctl enable clash
systemctl start clash


阅读全文...

Oct 25

群辉NGINX配置文件

include /etc/nginx/conf.d/*.conf;
location / {
    if (!-e $request_filename) {
        rewrite ^/(\d+)\.html(.*)$  /index.php?a=s&bid=$1$2 redirect;
        rewrite ^/v.html$ index.php?a=v redirect;
        rewrite ^/c(\d+)\.html$ index.php?a=c&sid=$1 redirect;
    }
}

https://freessl.cn

阅读全文...