step one of launch instance
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user