nginx docs + webhook debug
This commit is contained in:
41
docs/REVERSE_PROXY.md
Executable file
41
docs/REVERSE_PROXY.md
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
## Reverse proxy configuration
|
||||||
|
|
||||||
|
Submitted by [s33d1ing](https://github.com/s33d1ing).
|
||||||
|
|
||||||
|
|
||||||
|
Reverse proxy example by using LinuxServer's SWAG container.
|
||||||
|
|
||||||
|
### nginx config
|
||||||
|
|
||||||
|
|
||||||
|
``` nginx
|
||||||
|
location /pialert {
|
||||||
|
return 301 $scheme://$host/pialert/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ^~ /pialert/ {
|
||||||
|
include /config/nginx/proxy.conf;
|
||||||
|
include /config/nginx/resolver.conf;
|
||||||
|
|
||||||
|
set $upstream_app pialert;
|
||||||
|
set $upstream_port 20211;
|
||||||
|
set $upstream_proto http;
|
||||||
|
|
||||||
|
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
|
||||||
|
proxy_set_header Accept-Encoding "";
|
||||||
|
|
||||||
|
proxy_redirect ~^/(.*)$ /pialert/$1;
|
||||||
|
rewrite ^/pialert/?(.*)$ /$1 break;
|
||||||
|
|
||||||
|
sub_filter_once off;
|
||||||
|
sub_filter_types *;
|
||||||
|
|
||||||
|
sub_filter 'href="/' 'href="/pialert/';
|
||||||
|
|
||||||
|
sub_filter '(?>$host)/css' '/pialert/css';
|
||||||
|
sub_filter '(?>$host)/img' '/pialert/img';
|
||||||
|
sub_filter '(?>$host)/js' '/pialert/js';
|
||||||
|
sub_filter '(?>$host)/lib' '/pialert/lib';
|
||||||
|
sub_filter '(?>$host)/php' '/pialert/php';
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -302,17 +302,26 @@ def get_file_content(path):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def write_file (pPath, pText):
|
def write_file(pPath, pText):
|
||||||
# Write the text depending using the correct python version
|
# Convert pText to a string if it's a dictionary
|
||||||
|
if isinstance(pText, dict):
|
||||||
|
pText = json.dumps(pText)
|
||||||
|
|
||||||
|
# Convert pText to a string if it's a list
|
||||||
|
if isinstance(pText, list):
|
||||||
|
for item in pText:
|
||||||
|
write_file(pPath, item)
|
||||||
|
|
||||||
|
# Write the text using the correct Python version
|
||||||
if sys.version_info < (3, 0):
|
if sys.version_info < (3, 0):
|
||||||
file = io.open (pPath , mode='w', encoding='utf-8')
|
file = io.open(pPath, mode='w', encoding='utf-8')
|
||||||
file.write ( pText.decode('unicode_escape') )
|
file.write(pText.decode('unicode_escape'))
|
||||||
file.close()
|
file.close()
|
||||||
else:
|
else:
|
||||||
file = open (pPath, 'w', encoding='utf-8')
|
file = open(pPath, 'w', encoding='utf-8')
|
||||||
if pText is None:
|
if pText is None:
|
||||||
pText = ""
|
pText = ""
|
||||||
file.write (pText)
|
file.write(pText)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ def importConfigs (db):
|
|||||||
conf.PHOLUS_ACTIVE = ccd('PHOLUS_ACTIVE', False , c_d, 'Enable Pholus scans', 'boolean', '', 'Pholus')
|
conf.PHOLUS_ACTIVE = ccd('PHOLUS_ACTIVE', False , c_d, 'Enable Pholus scans', 'boolean', '', 'Pholus')
|
||||||
conf.PHOLUS_TIMEOUT = ccd('PHOLUS_TIMEOUT', 20 , c_d, 'Pholus timeout', 'integer', '', 'Pholus')
|
conf.PHOLUS_TIMEOUT = ccd('PHOLUS_TIMEOUT', 20 , c_d, 'Pholus timeout', 'integer', '', 'Pholus')
|
||||||
conf.PHOLUS_FORCE = ccd('PHOLUS_FORCE', False , c_d, 'Pholus force check', 'boolean', '', 'Pholus')
|
conf.PHOLUS_FORCE = ccd('PHOLUS_FORCE', False , c_d, 'Pholus force check', 'boolean', '', 'Pholus')
|
||||||
conf.PHOLUS_RUN = ccd('PHOLUS_RUN', 'once' , c_d, 'Pholus enable schedule', 'selecttext', "['none', 'once', 'schedule']", 'Pholus')
|
conf.PHOLUS_RUN = ccd('PHOLUS_RUN', 'once' , c_d, 'Pholus enable schedule', 'selecttext', "['disabled', 'once', 'schedule']", 'Pholus')
|
||||||
conf.PHOLUS_RUN_TIMEOUT = ccd('PHOLUS_RUN_TIMEOUT', 600 , c_d, 'Pholus timeout schedule', 'integer', '', 'Pholus')
|
conf.PHOLUS_RUN_TIMEOUT = ccd('PHOLUS_RUN_TIMEOUT', 600 , c_d, 'Pholus timeout schedule', 'integer', '', 'Pholus')
|
||||||
conf.PHOLUS_RUN_SCHD = ccd('PHOLUS_RUN_SCHD', '0 4 * * *' , c_d, 'Pholus schedule', 'text', '', 'Pholus')
|
conf.PHOLUS_RUN_SCHD = ccd('PHOLUS_RUN_SCHD', '0 4 * * *' , c_d, 'Pholus schedule', 'text', '', 'Pholus')
|
||||||
conf.PHOLUS_DAYS_DATA = ccd('PHOLUS_DAYS_DATA', 0 , c_d, 'Pholus keep days', 'integer', '', 'Pholus')
|
conf.PHOLUS_DAYS_DATA = ccd('PHOLUS_DAYS_DATA', 0 , c_d, 'Pholus keep days', 'integer', '', 'Pholus')
|
||||||
@@ -152,7 +152,7 @@ def importConfigs (db):
|
|||||||
# Nmap
|
# Nmap
|
||||||
conf.NMAP_ACTIVE = ccd('NMAP_ACTIVE', True , c_d, 'Enable Nmap scans', 'boolean', '', 'Nmap')
|
conf.NMAP_ACTIVE = ccd('NMAP_ACTIVE', True , c_d, 'Enable Nmap scans', 'boolean', '', 'Nmap')
|
||||||
conf.NMAP_TIMEOUT = ccd('NMAP_TIMEOUT', 150 , c_d, 'Nmap timeout', 'integer', '', 'Nmap')
|
conf.NMAP_TIMEOUT = ccd('NMAP_TIMEOUT', 150 , c_d, 'Nmap timeout', 'integer', '', 'Nmap')
|
||||||
conf.NMAP_RUN = ccd('NMAP_RUN', 'none' , c_d, 'Nmap enable schedule', 'selecttext', "['none', 'once', 'schedule']", 'Nmap')
|
conf.NMAP_RUN = ccd('NMAP_RUN', 'disabled' , c_d, 'Nmap enable schedule', 'selecttext', "['disabled', 'once', 'schedule']", 'Nmap')
|
||||||
conf.NMAP_RUN_SCHD = ccd('NMAP_RUN_SCHD', '0 2 * * *' , c_d, 'Nmap schedule', 'text', '', 'Nmap')
|
conf.NMAP_RUN_SCHD = ccd('NMAP_RUN_SCHD', '0 2 * * *' , c_d, 'Nmap schedule', 'text', '', 'Nmap')
|
||||||
conf.NMAP_ARGS = ccd('NMAP_ARGS', '-p -10000' , c_d, 'Nmap custom arguments', 'text', '', 'Nmap')
|
conf.NMAP_ARGS = ccd('NMAP_ARGS', '-p -10000' , c_d, 'Nmap custom arguments', 'text', '', 'Nmap')
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ def send (msg: noti_struc):
|
|||||||
logResult (stdout, stderr) # TO-DO should be changed to mylog
|
logResult (stdout, stderr) # TO-DO should be changed to mylog
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
# An error occured, handle it
|
# An error occured, handle it
|
||||||
mylog('none', ['[send_webhook]', e.output])
|
mylog('none', ['[send_webhook] Error', e.output])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ def send_notifications (db):
|
|||||||
|
|
||||||
msg = noti_struc(json_final, mail_text, mail_html)
|
msg = noti_struc(json_final, mail_text, mail_html)
|
||||||
|
|
||||||
mylog('info', ['[Notification] Udateing API files'])
|
mylog('info', ['[Notification] Udating API files'])
|
||||||
send_api()
|
send_api()
|
||||||
|
|
||||||
if conf.REPORT_MAIL and check_config('email'):
|
if conf.REPORT_MAIL and check_config('email'):
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ def cleanResult(str):
|
|||||||
if str.endswith('.'):
|
if str.endswith('.'):
|
||||||
str = str[:-1]
|
str = str[:-1]
|
||||||
|
|
||||||
return str(str)
|
return str
|
||||||
|
|
||||||
|
|
||||||
# Disclaimer - I'm interfacing with a script I didn't write (pholus3.py) so it's possible I'm missing types of answers
|
# Disclaimer - I'm interfacing with a script I didn't write (pholus3.py) so it's possible I'm missing types of answers
|
||||||
@@ -157,7 +157,8 @@ def resolve_device_name_pholus (pMAC, pIP, allRes):
|
|||||||
# _esphomelib._tcp.local. PTR Class:IN "ceiling-light-1._esphomelib._tcp.local."
|
# _esphomelib._tcp.local. PTR Class:IN "ceiling-light-1._esphomelib._tcp.local."
|
||||||
for i in pholusMatchesIndexes:
|
for i in pholusMatchesIndexes:
|
||||||
if checkIPV4(allRes[i]['IP_v4_or_v6']) and 'PTR Class:IN' in allRes[i]["Value"]:
|
if checkIPV4(allRes[i]['IP_v4_or_v6']) and 'PTR Class:IN' in allRes[i]["Value"]:
|
||||||
return cleanResult(allRes[i]["Value"].split('"')[1])
|
if allRes[i]["Value"] and len(allRes[i]["Value"].split('"')) > 1:
|
||||||
|
return cleanResult(allRes[i]["Value"].split('"')[1])
|
||||||
|
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user