Monitor: Change to be able to run TLS-less

NB: Not yet changed the actual monitor web page files.
This commit is contained in:
Athanasius 2022-03-13 13:59:15 +00:00
parent 1166b814b5
commit e8fa824b9d
4 changed files with 55 additions and 11 deletions

View File

@ -1,4 +1,4 @@
# vim: :filetype=apache
# vim: :filetype=apache tabstop=4 shiftwidth=4 expandtab
###########################################################################
#
@ -161,11 +161,26 @@
ProxyPreserveHost On
ProxyRequests Off
####################################
# Gateway, both /upload/ and /stats/ etc
####################################
<Location "/">
# Plain http if setting **empty** CERT_FILE and KEY_FILE in
# the EDDN config.json, else https.
ProxyPass "http://127.0.0.1:8081/"
# Plain http if setting **empty** CERT_FILE and KEY_FILE in
# the EDDN config.json, else https.
ProxyPass "http://127.0.0.1:8081/"
</Location>
####################################
####################################
# Monitor, /getSoftwares/ etc
####################################
<Location "/monitor/">
# Plain http if setting **empty** CERT_FILE and KEY_FILE in
# the EDDN config.json, else https.
ProxyPass "http://127.0.0.1:9091/"
</Location>
####################################
</IfModule>
</VirtualHost>
</IfModule>

View File

@ -531,10 +531,15 @@ config.json. See `contrib/apache-eddn.conf` for how to use TLS instead:
ProxyPreserveHost On
ProxyRequests Off
# Pass through anything with path prefix /eddn
# Pass through anything with path prefix /eddn to the Gateway
<Location "/eddn/">
ProxPass "http://127.0.0.1:8081/"
</Location>
# Anything with /monitor/ is for the Monitor
<Location "/eddn/monitor/">
ProxPass "http://127.0.0.1:9091/"
</Location>
</IfModule>
This assumes you don't have a dedicated virtual host in this case, hence the

View File

@ -451,7 +451,7 @@ def main() -> None:
argsd["keyfile"] = Settings.KEY_FILE
app.run(
**argsd
**argsd,
)

View File

@ -4,6 +4,7 @@
import argparse
import collections
import datetime
import logging
import zlib
from threading import Thread
from typing import OrderedDict
@ -23,6 +24,16 @@ monkey.patch_all()
app = Bottle()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
__logger_channel = logging.StreamHandler()
__logger_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(module)s:%(lineno)d: %(message)s")
__logger_formatter.default_time_format = "%Y-%m-%d %H:%M:%S"
__logger_formatter.default_msec_format = "%s.%03d"
__logger_channel.setFormatter(__logger_formatter)
logger.addHandler(__logger_channel)
logger.info("Made logger")
# This import must be done post-monkey-patching!
if Settings.RELAY_DUPLICATE_MAX_MINUTES:
from eddn.core.DuplicateMessages import DuplicateMessages
@ -30,6 +41,8 @@ if Settings.RELAY_DUPLICATE_MAX_MINUTES:
duplicate_messages = DuplicateMessages()
duplicate_messages.start()
from eddn.core.EDDNWSGIHandler import EDDNWSGIHandler
def parse_cl_args():
"""Parse command-line arguments."""
@ -286,12 +299,23 @@ def main() -> None:
m = Monitor()
m.start()
app.add_hook("after_request", apply_cors)
# Build arg dict for args
argsd = {
'host': Settings.MONITOR_HTTP_BIND_ADDRESS,
'port': Settings.MONITOR_HTTP_PORT,
'server': "gevent",
'log': gevent.pywsgi.LoggingLogAdapter(logger),
'handler_class': EDDNWSGIHandler,
}
# Empty CERT_FILE or KEY_FILE means don't put them in
if Settings.CERT_FILE != "" and Settings.KEY_FILE != "":
argsd["certfile"] = Settings.CERT_FILE
argsd["keyfile"] = Settings.KEY_FILE
app.run(
host=Settings.MONITOR_HTTP_BIND_ADDRESS,
port=Settings.MONITOR_HTTP_PORT,
server="gevent",
certfile=Settings.CERT_FILE,
keyfile=Settings.KEY_FILE,
**argsd,
)