Narzędzia użytkownika

Narzędzia witryny


openvpn_-_użytkownicy_i_prosty_panel

Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

Poprzednia rewizja po obu stronachPoprzednia wersja
Nowa wersja
Poprzednia wersja
openvpn_-_użytkownicy_i_prosty_panel [2015/09/29 09:52] kamilopenvpn_-_użytkownicy_i_prosty_panel [2018/07/16 11:47] (aktualna) – edycja zewnętrzna 127.0.0.1
Linia 18: Linia 18:
 mkdir -p /usr/share/nginx/o/ mkdir -p /usr/share/nginx/o/
 cd /usr/share/nginx/o/ cd /usr/share/nginx/o/
-wget http://kamil.orchia.pl/tmp/simple_openvpn_panel.7z +svn export http://svn.code.sf.net/p/openvpn-simple-panel/code/trunk/ ./o 
-7z simple_openvpn_panel.7z +chmod +x ./o/scripts/* 
-rm simple_openvpn_panel.7z+chmod -R o-rwx /usr/share/nginx/
 +chown -R www-data:www-data /usr/share/nginx/o
 </file> </file>
 ==== Konfiguracja ==== ==== Konfiguracja ====
Linia 35: Linia 36:
 mkdir /etc/openvpn/server mkdir /etc/openvpn/server
 cp ./keys/{ca.crt,dh1024.pem,server.crt,server.key} /etc/openvpn/server/ cp ./keys/{ca.crt,dh1024.pem,server.crt,server.key} /etc/openvpn/server/
-nano /etc/openvpn/server/server.conf+</file> 
 + 
 +Przykładowy plik /etc/openvpn/server/server.ovpn: 
 + 
 +<file> 
 +local 1.2.2.33 
 +port 12345 
 +proto tcp 
 +dev tap 
 +ca /etc/openvpn/server/ca.crt 
 +cert /etc/openvpn/server/server.crt 
 +key /etc/openvpn/server/server.key 
 +dh /etc/openvpn/server/dh1024.pem 
 +server 1.2.3.0 255.255.255.0 
 +ifconfig-pool-persist /etc/openvpn/server/ipp.txt 
 +push "route 10.20.0.0 255.255.255.0" 
 +client-to-client 
 +keepalive 10 120 
 +persist-key 
 +persist-tun 
 +status /usr/share/nginx/o/openvpn-status.log 
 +log /etc/openvpn/server/openvpn.log 
 +verb 3 
 +auth SHA1 
 +cipher AES-128-CBC 
 +tls-cipher DHE-RSA-AES128-SHA 
 +client-cert-not-required 
 +username-as-common-name 
 +client-connect /usr/share/nginx/o/scripts/client_connect.sh 
 +client-disconnect /usr/share/nginx/o/scripts/client_disconnect.sh 
 +script-security 2 
 +auth-user-pass-verify /usr/share/nginx/o/scripts/checkpass.sh via-file 
 +up /etc/openvpn/server/up.sh 
 +</file> 
 + 
 +Przykładowy plik /etc/openvpn/server/openvpn.sh: 
 +<file> 
 +#!/bin/bash 
 + 
 +pidfile="/etc/openvpn/server/pid" 
 + 
 +pid="" 
 + 
 +if [ -f $pidfile ]; 
 +then 
 +        pid=`cat $pidfile` 
 +fi 
 + 
 +start() 
 +
 +        if [ "$pid" != "" ]; 
 +        then 
 +                if [ "`ps aux | grep $pid | grep -v grep | wc -l`" == "1" ]; 
 +                then 
 +                        echo "OpenVPN is already started!" 
 +                else 
 +                        openvpn --cd /etc/openvpn/server/ --config server.ovpn --daemon --writepid $pidfile 
 +                fi 
 +        else 
 +                openvpn --cd /etc/openvpn/server/ --config server.ovpn --daemon --writepid $pidfile 
 +        fi 
 +
 + 
 +stop() 
 +
 +        if [ "$pid" != "" ]; 
 +        then 
 +                if [ "`ps aux | grep $pid | grep -v grep | wc -l`" == "1" ]; 
 +                then 
 +                        kill $pid 
 +                        echo "" > $pidfile 
 +                fi 
 +         fi 
 +
 + 
 +restart() 
 +
 +        stop 
 +        sleep 5 
 +        start 
 +
 + 
 +case "$1" in 
 +        'start'
 +        echo -ne "Starting OpenVPN... " 
 +        start 
 +        echo "OK" 
 +        ;; 
 +        'restart'
 +        echo -ne "Restarting OpenVPN... " 
 +        stop 
 +        sleep 5 
 +        start 
 +        echo "OK" 
 +        ;; 
 +        'stop'
 +        echo -ne "Stopping OpenVPN... " 
 +        stop 
 +        echo "OK" 
 +        ;; 
 +        *) 
 +        echo -e "\n Usage: openvpn.sh { start | stop | restart }" 
 +        ;; 
 +esac 
 +</file> 
 + 
 +Plik /etc/openvpn/server/up.sh: 
 +<file> 
 +#!/bin/sh 
 + 
 +chmod o+r /usr/share/nginx/o/openvpn-status.log 
 +</file> 
 + 
 +Nadajemy uprawnienia i uruchamiamy OpenVPN: 
 + 
 +<file> 
 +chmod 700 /etc/openvpn/server/*.sh 
 +/etc/openvpn/server/openvpn.sh start 
 +</file> 
 + 
 +Przykładowy plik client.ovpn, który dołączamy z plikiem ca.crt: 
 +<file> 
 +client 
 +dev tap 
 +proto tcp 
 +remote 1.2.2.33 12345 
 +resolv-retry infinite 
 +nobind 
 +persist-key 
 +persist-tun 
 +ca ca.crt 
 +ns-cert-type server 
 +verb 3 
 +auth-user-pass 
 +auth SHA1 
 +cipher AES-128-CBC 
 +tls-cipher DHE-RSA-AES128-SHA
 </file> </file>
  
Linia 99: Linia 236:
         location /o/ {         location /o/ {
                 alias /usr/share/nginx/o/public/;                 alias /usr/share/nginx/o/public/;
-                allow 1.2.3.0/16;+                allow 1.2.3.0/24;
                 deny all;                 deny all;
                 auth_basic "Restricted!";                 auth_basic "Restricted!";
Linia 116: Linia 253:
 Przy generowaniu htpasswd pomoże nam link: [[http://kamil.orchia.pl/php/nginx.php]] Przy generowaniu htpasswd pomoże nam link: [[http://kamil.orchia.pl/php/nginx.php]]
  
 +Sekcję allow i deny ustawiamy dopiero po dodaniu pierwszego użytkownika.
  
 +Kopiujemy plik /usr/share/nginx/o/config/config.ini.example:
 +<file>
 +cp /usr/share/nginx/o/config/config.ini.example /usr/share/nginx/o/config/config.ini
 +</file>
  
 +Konfiguracja panelu jest odczytywana z pliku: /usr/share/nginx/o/config/config.ini
  
 +Uwaga! Pliki /usr/share/nginx/o/scripts/genfw.php oraz /usr/share/nginx/o/scripts/reload.php należy dostosować pod swoją konfigurację.
 +
 +Crontab:
 +
 +<file>
 +*/5 * * * * root cd /usr/share/nginx/o/scripts && ./reload.php
 +</file>
openvpn_-_użytkownicy_i_prosty_panel.1443513175.txt.gz · ostatnio zmienione: 2018/07/16 11:47 (edycja zewnętrzna)