diff --git a/routes/__pycache__/main.cpython-313.pyc b/routes/__pycache__/main.cpython-313.pyc index b18bbe3..41d000d 100644 Binary files a/routes/__pycache__/main.cpython-313.pyc and b/routes/__pycache__/main.cpython-313.pyc differ diff --git a/routes/admin_api.py b/routes/admin_api.py index f044450..fad2521 100644 --- a/routes/admin_api.py +++ b/routes/admin_api.py @@ -572,11 +572,33 @@ def test_nginx_connection(): return jsonify({'error': 'Missing required fields'}), 400 try: - # Test NGINX Proxy Manager connection + # First, get the JWT token + token_response = requests.post( + f"{url.rstrip('/')}/api/tokens", + json={ + 'identity': username, + 'secret': password + }, + headers={'Content-Type': 'application/json'}, + timeout=5 + ) + + if token_response.status_code != 200: + return jsonify({'error': 'Failed to authenticate with NGINX Proxy Manager'}), 400 + + token_data = token_response.json() + token = token_data.get('token') + + if not token: + return jsonify({'error': 'No token received from NGINX Proxy Manager'}), 400 + + # Now test the connection using the token response = requests.get( f"{url.rstrip('/')}/api/nginx/proxy-hosts", - auth=(username, password), - headers={'Accept': 'application/json'}, + headers={ + 'Authorization': f'Bearer {token}', + 'Accept': 'application/json' + }, timeout=5 ) diff --git a/routes/main.py b/routes/main.py index f237b08..cae30ba 100644 --- a/routes/main.py +++ b/routes/main.py @@ -376,7 +376,14 @@ def init_routes(main_bp): db.session.commit() - return render_template('main/instances.html', instances=instances) + # Get connection settings + portainer_settings = KeyValueSettings.get_value('portainer_settings') + nginx_settings = KeyValueSettings.get_value('nginx_settings') + + return render_template('main/instances.html', + instances=instances, + portainer_settings=portainer_settings, + nginx_settings=nginx_settings) @main_bp.route('/instances/add', methods=['POST']) @login_required diff --git a/templates/main/instances.html b/templates/main/instances.html index dc68d1e..1bb01e4 100644 --- a/templates/main/instances.html +++ b/templates/main/instances.html @@ -122,24 +122,230 @@ + + + + +