diff --git a/jetforce/__main__.py b/jetforce/__main__.py index 64a9f0e..9eab9e6 100644 --- a/jetforce/__main__.py +++ b/jetforce/__main__.py @@ -70,6 +70,13 @@ group.add_argument( help="A directory containing CA files for validating clients", metavar="DIR", ) +group.add_argument( + "--reverse-proxy", + help="Enable reverse proxy mode where TLS is handled by a reverse proxy such as Nginx", + action='store_true', + default=False, + dest="reverse_proxy", + ) group = parser.add_argument_group("fileserver configuration") group.add_argument( "--dir", @@ -105,13 +112,6 @@ group.add_argument( default=None, dest="rate_limit", ) -group.add_argument( - "--reverse-proxy", - help="Enable reverse proxy mode where TLS is handled by a reverse proxy such as Nginx", - action='store_true', - default=False, - dest="reverse_proxy", - ) group.add_argument( "--markdown", help="Enable markdown to gemini mode.", @@ -128,6 +128,12 @@ def main() -> None: app_class = StaticMarkdownDirectoryApplication else: app_class = StaticDirectoryApplication + if args.reverse_proxy: + server_class = ReverseProxyGeminiServer + args.certfile = False + args.keyfile = False + else: + server_class = GeminiServer app = app_class( root_directory=args.root_directory, index_file=args.index_file, @@ -135,15 +141,7 @@ def main() -> None: default_lang=args.default_lang, rate_limiter=rate_limiter, ) - if args.reverse_proxy: - server = ReverseProxyGeminiServer( - app=app, - host=args.host, - port=args.port, - hostname=args.hostname, - ) - else: - server = GeminiServer( + server = server_class( app=app, host=args.host, port=args.port, diff --git a/jetforce/server.py b/jetforce/server.py index fa2f6dc..e90a169 100644 --- a/jetforce/server.py +++ b/jetforce/server.py @@ -143,7 +143,7 @@ class ReverseProxyGeminiServer(GeminiServer): endpoint_class = TCP4ServerEndpoint def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs, certfile=False) + super().__init__(*args, **kwargs) def initialize(self) -> None: """