差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:pve_openvpn [2023/07/10 23:08] – [安裝 openvpn-snmp-stats 強化監控] jonathantech:pve_openvpn [2023/10/29 00:44] (目前版本) jonathan
行 1: 行 1:
-====== PVE 內使用 CT Template 安裝 OpenVPN Server ======+====== 安裝 OpenVPN Server(使用 PVE 內 CT Template) ======
   * 採用 PVE 可下載的 CT Template - debian-10-turnkey-openvpn_16.1-1_amd64.tar.gz 來建立   * 採用 PVE 可下載的 CT Template - debian-10-turnkey-openvpn_16.1-1_amd64.tar.gz 來建立
  
行 148: 行 148:
  
 <note tip> <note tip>
-  * 如果想讓 OpenVPN 的 Listen Port 改為 443, 因為會與提供下載憑證的 lighttpd 衝突, 所以需要 +  * 如果想讓 OpenVPN 的 Listen Port 改為 443, 因為會與提供下載憑證的 lighttpd 衝突, 所以可以修改 SSL Port 為其他 port Exp. 20443 
-    * 修改 /etc/lighttpd/lighttpd.conf 的設定 Exp. 改成 20443 <cli>+    * [舊版] 修改 /etc/lighttpd/lighttpd.conf 的設定<cli>
 vi /etc/lighttpd/lighttpd.conf vi /etc/lighttpd/lighttpd.conf
 +</cli><file>
 +:
 +$SERVER["socket"] == ":80" {
 +    $HTTP["host"] =~ "(.*)" {
 +        url.redirect = ( "^/(.*)" => "https://%1/$1" )
 +    }
 +}
 +
 +$SERVER["socket"] == ":20443" {
 +    ssl.engine = "enable"
 +    # Note using shared hardened SSL settings
 +    include "ssl-params.conf"
 +:
 +</file>
 +    * [新版] 修改 /etc/lighttpd/conf-enabled/50-tklcp.conf <cli>
 +vi /etc/lighttpd/conf-enabled/50-tklcp.conf
 </cli><file> </cli><file>
 : :
行 165: 行 181:
 : :
 </file><cli> </file><cli>
 +vi /etc/lighttpd/conf-enabled/10-ssl.conf
 +</cli><file>
 +:
 +$SERVER["socket"] == "0.0.0.0:20443" {
 +    ssl.engine  = "enable"
 +}
 +:
 +# support for IPv6 HTTPS via Debian script (in 'lighttpd' package)
 +include_shell "/usr/share/lighttpd/use-ipv6.pl 20443"
 +</file>修改好重啟 lighttpd<cli>
 systemctl restart lighttpd.service systemctl restart lighttpd.service
 </cli> </cli>
行 219: 行 245:
 -A INPUT -p udp -m udp --dport 161 -j ACCEPT  -A INPUT -p udp -m udp --dport 161 -j ACCEPT 
 : :
-</file>更改後重啟主機讓 firewall 生效+</file>更改後重啟主機或是使用 iptable-restore 讓 firewall 生效<cli> 
 +iptable-restore < /etc/iptables.up.rules 
 +</cli>
  
 ===== 安裝 openvpn-snmp-stats 強化監控 ===== ===== 安裝 openvpn-snmp-stats 強化監控 =====
行 248: 行 276:
 </cli> </cli>
   * 可以至 LibreNMS 針對這台主機開啟 Applications -> Wireguard 就可以出現類似以下的畫面 \\ {{:tech:2023-07-10_230252.png?1024|}}    * 可以至 LibreNMS 針對這台主機開啟 Applications -> Wireguard 就可以出現類似以下的畫面 \\ {{:tech:2023-07-10_230252.png?1024|}} 
 +
 +===== 安裝 openvpn-monitor 強化監控 =====
 +  * 參考 - https://registry.hub.docker.com/r/ruimarinho/openvpn-monitor
 +  * 在 openvpn server 開啟監控服務 Port Exp. 5555<cli>
 +vi /etc/openvpn/server.conf
 +</cli><file>
 +:
 +status /var/log/openvpn/server.log
 +verb 4
 +management 0.0.0.0 5555
 +:
 +</file>
 +  * 重啟 openvpn server 讓設定生效, 可以使用 netstat 查看是否 port 5555 已經開啟<cli>
 +root@ct-devops-vpn ~# netstat -lntp | grep openvpn
 +tcp        0      0 0.0.0.0:5555            0.0.0.0:              LISTEN      88842/openvpn       
 +tcp        0      0 0.0.0.0:443             0.0.0.0:              LISTEN      88842/openvpn    
 +</cli>
 +  * 參考 [[tech:openvpn-monitor]] 
 +
 ===== 參考網址 ===== ===== 參考網址 =====
   * https://forum.proxmox.com/threads/openvpn-in-the-lxc.41889/   * https://forum.proxmox.com/threads/openvpn-in-the-lxc.41889/
  • tech/pve_openvpn.1689001731.txt.gz
  • 上一次變更: 2023/07/10 23:08
  • jonathan