helloworld

目前分類:系統管理 (418)

瀏覽方式: 標題列表 簡短摘要

因為疫情關係
很多公司行號都在演練異地或是居家辦公,WFH (work from home)

vpn 是一個方式
但如果已經習慣辦公場所的電腦環境
沒有他不行的話

現有遠端連現有幾個方式可以使用
可以使用商業軟體如 team viewer
team viewer 的好處是
可以不受防火牆限制
dhcp client 也不用特別去記目前的ip

windows 有內建的 remote desktop 
可以讓其他 windows 用戶連線到遠端主機的桌面
甚至是 iphone 和 mac os 也可以下載 app 連線到 windows remote desktop
https://apps.apple.com/tw/app/remote-desktop-mobile/id714464092

而 Mac OS 內建也有類似的設定

server 端
1. 系統偏好設定 -> 共享
image

2. 開啟螢幕共享 -> 桉 + 號 允許下列使用者存取
image

client 端
1. 前往  -> 連接伺服器
image

2. 輸入 vnc://IP:5900 , 連線即可
image

如果 client 是 windows 環境也可以下載 vnc viewer 連線
https://www.realvnc.com/en/connect/download/viewer/

undefined

文章標籤

helloworld 發表在 痞客邦 留言(1) 人氣()

如果在 CentOS + apache + php 的環境下面出現 Warning: file_get_contents(http://xxx): failed to open stream: Permission denied in xxx
或是一些摸不著頭緒的錯誤訊息

當確定程式沒有問題,在其他設備上也可以正常執行
請檢察看看 selinux 的設定
最簡單的方式就是 修改 /etc/selinux/config
SELINUX=disabled
重開機

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

根據網路上的說法
Bytespider 是字節跳動旗下的今日頭條正在開發搜索引擎所派出來的爬蟲
但頻率真的太高了
有些小網站根本受不了
如果要擋的話有幾個方式

1. robots.txt
不允許 Bytespider 來爬網站,但可能不會有效

2. apache rewrite rule 
判斷 agent 為 Bytespider 則回應 403

3. 防火牆直接擋在外面
這是最直接有效的方式,也不用讓人家進到web server 後再給人家拒絕
目前整理出來幾個網段可以參考
110.249.202.0/24
110.249.201.0/24
111.225.149.0/24
111.225.148.0/24
60.8.123.0/24
220.243.135.0/24
220.243.136.0/24
 

helloworld 發表在 痞客邦 留言(0) 人氣()

varnish 預設使用 regular expression 比對字串是有區分大小寫的
如 

if (req.http.User-Agent ~ "spider") {
    return (synth(403));
}

如果要不分大小寫比對字串時,可以在字串前面加入 (?i) 

if (req.http.User-Agent ~ "(?i)spider") {
    return (synth(403));
}
 

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

隨著顯卡和螢幕解析度大幅提高後
如果發現部分程式的顯示畫面或是文字模糊不清
可以嘗試以下方式解決,或許有機會可以解決

選取應用程式,點擊右鍵 -> 內容 -> 相容性 變更高DPI設定 將以下兩個checkbox 都勾選起來 確定離開

image

重新開啟應用程式看看顯示情形是否有改善

undefined

 

helloworld 發表在 痞客邦 留言(0) 人氣()

在 shell 下如果要用curl 指定IP抓取 virtual host 網頁內容可以用以下指令
# curl 'http://192.168.5.111/path/pagename' -H "Host: example.pass.tw"

相對於以上指令,如果要用php 執行的話
<?php
$ch = curl_init('http://192.168.5.111/path/pagename');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: example.pass.tw'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

AWStats 是一套強大的 opensource log 分析工具
可以分析來自 web , mail , ftp server 等格式的紀錄

以下測試環境:
FreeBSD 12.1-RELEASE
apache24/httpd-2.4.41
awstats-7.7

更新ports
# portsnap fetch update

安裝 apache24
# cd /usr/ports/www/apache24/
# make install clean

接下來安裝 AWStats
# cd /usr/ports/www/awstats/
# make install clean

設定apache, 將以下註解拿掉
# cd /usr/local/etc/apache24/
# vi httpd.conf
LoadModule cgid_module libexec/apache24/mod_cgid.so

設定vhost , 如果這台是單一功能的機器也可以直接寫在 httpd.conf 內
# cd /usr/local/etc/apache24/Includes/
# vi awstats.conf
<VirtualHost *:80>
        ServerAdmin webadm@staff.pass.tw
        ServerName awstats.pass.tw
        ErrorLog /home/archive/logs/error_log-awstats.log
        CustomLog /home/archive/logs/access_log-awstats.log combined

        Alias /awstatsclasses "/usr/local/www/awstats/classes/"
        Alias /awstatscss "/usr/local/www/awstats/css/"
        Alias /awstatsicons "/usr/local/www/awstats/icon/"
        ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"

        <Directory "/usr/local/www/awstats/">
                Options None
                AllowOverride None
                Require all granted
        </Directory>
        <Directory "/usr/local/www/awstats/cgi-bin/">
                Options ExecCGI
                SetHandler cgi-script
        </Directory>
</VirtualHost>

重新啟動apache
# apachectl restart

編輯設定檔,簡單調整適合自己的設定
# cd /usr/local/www/awstats/cgi-bin/
# cp awstats.model.conf awstats.pass.tw.conf
# vi awstats.pass.tw.conf
LogFile="gzip -cd /home/workdir/access_log.pass.tw*.gz |"
LogType=W
LogFormat=1
LogSeparator=" "
SiteDomain="books.pass.tw"
DirData="/usr/local/www/awstats/data"

開始分析數據
# mkdir /usr/local/www/awstats/data
# /usr/local/www/awstats/cgi-bin/awstats.pl -config=pass.tw -update

打開瀏覽器,網址輸入
http://主機名稱或ip/awstats/awstats.pl?config=設定檔

http://awstats.pass.tw/awstats/awstats.pl?config=pass.tw

測試如果正常的話,將 /usr/local/www/awstats/cgi-bin/awstats.pl 寫入 crontab 每日固定時間執行即可

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

FreeBSD 安裝 AWStats

AWStats 是一套強大的 opensource log 分析工具
可以分析來自 web , mail , ftp server 等格式的紀錄

以下測試環境:
FreeBSD 12.1-RELEASE
apache24/httpd-2.4.41
awstats-7.7

更新ports
# portsnap fetch update

安裝 apache24
# cd /usr/ports/www/apache24/
# make install clean

接下來安裝 AWStats
# cd /usr/ports/www/awstats/
# make install clean

設定apache, 將以下註解拿掉
# cd /usr/local/etc/apache24/
# vi httpd.conf
LoadModule cgid_module libexec/apache24/mod_cgid.so

設定vhost , 如果這台是單一功能的機器也可以直接寫在 httpd.conf 內
# cd /usr/local/etc/apache24/Includes/
# vi awstats.conf
<VirtualHost *:80>
        ServerAdmin webadm@staff.pass.tw
        ServerName awstats.pass.tw
        ErrorLog /home/archive/logs/error_log-awstats.log
        CustomLog /home/archive/logs/access_log-awstats.log combined

        Alias /awstatsclasses "/usr/local/www/awstats/classes/"
        Alias /awstatscss "/usr/local/www/awstats/css/"
        Alias /awstatsicons "/usr/local/www/awstats/icon/"
        ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"

        <Directory "/usr/local/www/awstats/">
                Options None
                AllowOverride None
                Require all granted
        </Directory>
        <Directory "/usr/local/www/awstats/cgi-bin/">
                Options ExecCGI
                SetHandler cgi-script
        </Directory>
</VirtualHost>

重新啟動apache
# apachectl restart

編輯設定檔,簡單調整適合自己的設定
# cd /usr/local/www/awstats/cgi-bin/
# cp awstats.model.conf awstats.pass.tw.conf
# vi awstats.pass.tw.conf
LogFile="gzip -cd /home/workdir/access_log.pass.tw*.gz |"
LogType=W
LogFormat=1
LogSeparator=" "
SiteDomain="books.pass.tw"
DirData="/usr/local/www/awstats/data"

開始分析數據
# mkdir /usr/local/www/awstats/data
# /usr/local/www/awstats/cgi-bin/awstats.pl -config=pass.tw -update

打開瀏覽器,網址輸入
http://主機名稱或ip/awstats/awstats.pl?config=設定檔

http://awstats.pass.tw/awstats/awstats.pl?config=pass.tw

測試如果正常的話,將 /usr/local/www/awstats/cgi-bin/awstats.pl 寫入 crontab 每日固定時間執行即可

undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

目前幾乎所有的瀏覽器都已支援壓縮功能
以下幾個網站可以方便檢測你的網站是否有開啟壓縮的功能
https://aruljohn.com/gziptest.php
https://www.whatsmyip.org/http-compression-test/
http://www.gidnetwork.com/tools/gzip-test.php

操作方式都一樣,只需輸入網址就可以方便知道結果


undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

情境
example.com/a/test.html -> a.example.com/test.html
example.com/b/test.html -> b.example.com/test.html

# vi /etc/varnish/default.vcl
 

vcl 4.0;

import directors;
import std;

[.... 中間略 ....]

sub vcl_recv {
    if (req.http.host ~ "example.com") {
        if (req.url ~ "^/a/") {
            set req.url = regsub(req.url, "^/a","");
            set req.http.host = "a.example.com";
            set req.backend_hint = a.backend();
        } else if (req.url ~ "^/b/") {
            set req.url = regsub(req.url, "^/b","");
            set req.http.host = "b.example.com";
            set req.backend_hint = b.backend();
        }
    }
}

undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

我們可能會遇到系統硬體不夠力,想要換一台新的NAS
或是空間不族,想要更換大一點的硬碟空間

首先除了先要把裡面的資料備份出來外
如果原來的設定很單純的話,當然可以直接在新機器上面設定
但是如果裡面很多的服務和帳號的話,建議還是用系統提供的備份還原機制

控制台 -> 更新 & 還原 -> 系統設定備份

1. 備份設定
系統會將以下的設定及帳號密碼備份出來一個 .dss 的檔案

2. 還原設定
(1) 選擇要還原哪一個備份檔

(2) 選擇要還原的設定及是否要覆寫衝突
如果是全新的設定的話,當然是全選
但是如果只是單純因為前一刻手誤,不小心改壞設定或是誤刪帳號,就可以選擇各別的設定還原






PS. 還原設定的時候不會異動到網路設定,所以可以不用擔心新舊兩台機器會有IP 衝突的狀況
 

undefined

 

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

測試Synology DS413 可以抓到單顆10TB硬碟
但是這個型號的NAS 每個 volume 的上限是 16TB
所以裝 10TB的硬碟很尷尬
做成 raid10 / raid5 / raid6 都會超過 16TB
只能做成兩個raid1 的 volume



官方資料
https://www.synology.com/zh-tw/knowledgebase/DSM/tutorial/Storage/Why_does_my_Synology_NAS_have_a_single_volume_size_limitation

因應現在硬碟空間愈做愈大,建議就買可以上到108TB 的機型

undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

手頭上剛好有 Dell R310 和 4顆SEAGATE 10TB的硬碟
想要來試試可不可以用舊機器裝一台空間大一點的NAS

進到 Raid BIOS , 很順利的抓到10TB的硬碟
也可以成功建立 Raid 5 && Virtual Disk

但進到CentOS 8 的安裝介面的時候,看不到剛剛建立的 Virtual Disk

結論: 失敗,冏
undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

首先介紹 runuser 這個指令

# runuser --help

Usage:
 runuser [options] -u <user> [[--] <command>]
 runuser [options] [-] [<user> [<argument>...]]

Run <command> with the effective user ID and group ID of <user>.  If -u is
not given, fall back to su(1)-compatible semantics and execute standard shell.
The options -c, -f, -l, and -s are mutually exclusive with -u.

Options:
 -u, --user <user>               username
 -m, -p, --preserve-environment  do not reset environment variables
 -g, --group <group>             specify the primary group
 -G, --supp-group <group>        specify a supplemental group

 -, -l, --login                  make the shell a login shell
 -c, --command <command>         pass a single command to the shell with -c
 --session-command <command>     pass a single command to the shell with -c
                                   and do not create a new session
 -f, --fast                      pass -f to the shell (for csh or tcsh)
 -s, --shell <shell>             run <shell> if /etc/shells allows it
 -P, --pty                       create a new pseudo-terminal

 -h, --help                      display this help
 -V, --version                   display version


For more details see runuser(1).

範例:
runuser -l mongod -c '/usr/bin/mongod -f /home/example/mongod-27020.conf'

runuser -l mongod -c '/usr/bin/mongod -f /home/example/mongod-27020.conf --shutdown'

透過這個做法,我們可以將開機後要執行的服務寫在同一支 script 中,方便重開機後自動執行,很方便喔

另外還有幾種作法,也是可以在root 的權限下,使用特定的使用者權限來執行程式,提供作參考
1. su - username
2. suid (set uid)
 

undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

https://www.apple.com/tw/macos/catalina/

macOS Catalina是蘋果公司用於麥金塔電腦的桌面作業系統 macOS 的第16個主要版本。它是 macOS Mojave 的繼任者,於2019年6月3日在蘋果全球開發者大會發布,並於2019年10月8日正式推出。Catalina 是第一個只支援64位元應用程式的 macOS 版本。
節錄自維基百科
https://zh.wikipedia.org/zh-tw/MacOS_Catalina

升級了這次的macOS 最主要的災情應該就是不能在執行原本已經安裝的32bit 軟體
如果是安裝舊版的microsoft office , 則會讓你安裝 office 365
之前跟微軟買斷的office 也只能跟這台電腦說881 

如果原來已經安裝了32bit的軟體也有可能因為升級,而無法 uninstall 
讓你看的到用不到,也丟不掉... orz

總之,這次升級前就好好三思一下

undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

1. 如果還沒安裝 portupgrade 套件,請先安裝該套件

# cd /usr/ports/ports-mgmt/portupgrade
# make install clean

2. 列出 portsclean 功能

#  portsclean -h
portsclean 2.4.15 (2019/10/04)

usage: portsclean [-hCDDiLnPPQQq]

    -h, --help         Show this message
    -C, --workclean    Clean up working directories
    -D, --distclean    Clean up distfiles which are not referenced from any
                       port in the ports tree;
                       Specified twice, clean up distfiles which are not
                       referenced from any port that is currently installed
    -i, --interactive  Turn on interactive mode
    -L, --libclean     Clean up old shared libraries
    -n, --noexecute    Do not actually delete files
    -P, --pkgclean     Clean up outdated package tarballs;
                       Specified twice, delete all the package tarballs
    -Q, --quiet        Do not write anything to stdout;
                       Specified twice, stderr neither
    -q, --noconfig     Do not read pkgtools.conf

Environment Variables [default]:
    PACKAGES         packages directory [$PORTSDIR/packages]
    PKGTOOLS_CONF    configuration file [$PREFIX/etc/pkgtools.conf]
    PKG_DBDIR        packages DB directory [/var/db/pkg]
    PORTSDIR         ports directory [/usr/ports]
    PORTS_DBDIR      ports db directory [$PORTSDIR]
    PORTS_INDEX      ports index file [$PORTSDIR/INDEX]


3. 刪除 work 資料匣

# portsclean -C
Cleaning out /usr/ports/*/*/work...
Delete /usr/ports/databases/pecl-mongodb/work
Delete /usr/ports/shells/bash/work
Delete /usr/ports/textproc/xmlto/work
Delete /usr/ports/textproc/asciidoc/work
Delete /usr/ports/devel/libatomic_ops/work
Delete /usr/ports/devel/boehm-gc/work
Delete /usr/ports/devel/git/work
Delete /usr/ports/devel/cvsps/work
Delete /usr/ports/www/w3m/work
Delete /usr/ports/security/p5-Authen-SASL/work
Delete /usr/ports/security/p5-Digest-HMAC/work
Delete /usr/ports/misc/getopt/work
Delete /usr/ports/lang/p5-Error/work
done.

undefined
精通 Shell 程式設計(第四版)
Shell Programming in Unix, Linux and OS X, 4th Edition

作者: Stephen G. Kochan, Patrick Wood  
譯者: 蔡明志
出版社:碁峰

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

安裝好 wordpress 5 ,修改永久連結(Permalinks) 後新增文章
如果出現 Publishing failed 或是 發佈時發生錯誤 等錯誤訊息

請確認 apache 的 rewrite module 是否有安裝並啟用
<Directory "/home/www/wp">
    ....
    AllowOverride All
    ....
</Directory>

並且在 wordpress 的目錄下面新增一個 .htaccess 檔案
內容如下

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp5/index.php [L]
</IfModule>



undefined
WordPress架站的12堂課增訂版:網域申請x架設x佈景主題x廣告申請

作者: 張正麒, 何敏煌  
出版社:碁峰 

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

在 vmware esxi 安裝 windows 10 如果出現 efi vmware virtual sata cdrom Drive (0.0) ... unsuccessful 錯誤訊息


可以檢查一下 VM Options 的設定
如果預設是選擇 EFI 的話,把他改成 BIOS 再重開機


undefined
VMware vSphere 6.7私有雲建置實戰

作者: 顧武雄  
出版社:碁峰 

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

在瀏覽器輸入 synology nas 的主機名稱或是ip 的話
預設會自動轉址到 5000 port
如果想要轉址到其他應用服務去的話

可以修改以下檔案
# vi /usr/syno/share/nginx/WWWService.mustache


server {
    listen 80 default_server{{#reuseport}} reuseport{{/reuseport}};
    listen [::]:80 default_server{{#reuseport}} reuseport{{/reuseport}};

    gzip on;

    {{> /usr/syno/share/nginx/WWW_Main}}

    location ~ ^/$ {
        //rewrite / http://$host:{{DSM.port}}/ redirect;
        //取代成想要轉址的port

        rewrite / http://$host:8080/ redirect;
    }
}

最後重啟服務
# synoservicecfg --restart nginx

undefined

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

家裡有台 Sony Bravia 42" 電視
因為有時候會自動重開機,所以想更新一下軟體
也想順便測試一下直接用電視看Youtube

由於這台TV沒有內建無線網卡,瞄一下背後,有usb port 和 RJ-45
但家裡只有手機熱點可以分享網路給其他設備
所以就先拿了一張usb無線網卡插上去
結果不支援,爬文之後才發現他只支援 Bravia 電視專用的無線網卡
如: UWA-BR100

但是這張卡單價不便宜,台灣也沒什麼通路在賣
所以只能接有線了

測試環境
手機熱點 <- wifi -> BR-6428nS <- Lan -> Sony Bravia TV

以下是用【EDIMAX 訊舟】BR-6428nS V4 N300多模式無線網路分享器 實測畫面

undefined

EDIMAX 訊舟 BR-6428nS V4 N300多模式無線網路分享器
 
--高增益天線+特調無線參數,效能超越同級產品20%--
 
延續前一代BR-6428nS V3 優異的無線傳輸技術,搭配高增益天線,不僅讓您可於大空間的無線網路環境下輕鬆使用。針對現代住宅多隔間與多樓層,訊號死角多的問題,BR-6428nS V4 的無線訊號延伸器模式(Extender Mode)也提供了專為延伸跨樓層、多房間的無線網路環境設計的無線訊號延伸功能,它能延伸家中現有的無線網路、有效減少訊號死角,大幅提昇上網品質。
 
在設定安裝方面,BR-6428nS V4 採用新一代iQ Setup快速設定功能,讓您使用手機即可無障礙安裝,連線上網更快更方便。同時,BR-6428nS V4 智慧五合一多模式設計,大幅簡化繁複設定,讓一台無線分享器可輕易變身為「無線訊號延伸器(Range Extender Mode)」、「無線基地台(Access Point Mode)」、「無線橋接器(AP Client)」及「無線公共熱點(WISP)」,使您的網路環境應用更添彈性,而這樣的功能切換,只要透過手機或平板執行iQSetup,您不必是行家也可輕鬆操作。
 
此外,BR-6428nS V4 同樣採用最新Green WLAN技術,內建新一代低溫無線晶片,可以主動調整資料傳輸所需電量,省電效果高達66%,重點是節能省電之外,絕對不省效能,讓您在馳騁無線網上的同時,也能為綠色環保盡一分心力。

1. 找一台電腦網卡設成dhcp自動抓取, 並接上 BR-6428nS 的Lan port
網址輸入 http://edimax.setup/
如果需要帳號密碼,出廠的預設值是 admin / 1234
選擇 WISP 模式


2. 選擇手動設定


3. 選擇一個基地台,也就是你手機的熱點


4. 輸入密碼


5. 下一步


6. 下一步


7. 設定你這台分享器的ssid 和密碼


8. 設定完成


9. 等待設備同步完設定


10. 恭喜,設定完成

接下來就是把電視和分享器用網路線接起來就可以了
 

文章標籤

helloworld 發表在 痞客邦 留言(0) 人氣()

Close

您尚未登入,將以訪客身份留言。亦可以上方服務帳號登入留言

請輸入暱稱 ( 最多顯示 6 個中文字元 )

請輸入標題 ( 最多顯示 9 個中文字元 )

請輸入內容 ( 最多 140 個中文字元 )

reload

請輸入左方認證碼:

看不懂,換張圖

請輸入驗證碼