@@ -352,6 +352,55 @@ def test_webserver_add_container_with_ssl_integration(
352352 stop_backend (backend )
353353
354354
355+ @pytest .mark .parametrize ("backend_type" , ["container" , "service" ])
356+ def test_proxy_full_redirect_to_https_target_integration (
357+ nginx_proxy_container : docker .models .containers .Container ,
358+ docker_client : docker .DockerClient ,
359+ test_network : docker .models .networks .Network ,
360+ backend_type : str ,
361+ ):
362+ """
363+ Test that PROXY_FULL_REDIRECT resolves a bare target to the existing HTTPS vhost
364+ and renders a documented 301 redirect without appending :80.
365+ """
366+ suffix = uuid .uuid4 ().hex [:6 ]
367+ target_host = f"{ backend_type } .full-redirect-target-{ suffix } .example.com"
368+ source_host = f"{ backend_type } .full-redirect-source-{ suffix } .example.com"
369+ env = {
370+ "VIRTUAL_HOST" : f"https://{ target_host } -> :8080" ,
371+ "VIRTUAL_PORT" : "8080" ,
372+ "PROXY_FULL_REDIRECT" : f"{ source_host } -> { target_host } " ,
373+ }
374+
375+ backend = start_backend (docker_client , test_network , env , backend_type = backend_type , sleep = False )
376+ try :
377+ redirect_server = None
378+ for _ in range (25 ):
379+ config_str = get_nginx_config_from_container (nginx_proxy_container [0 ])
380+ config = HttpBlock .parse (config_str )
381+ redirect_server = next ((s for s in config .servers if source_host in s .server_names ), None )
382+ if redirect_server is not None :
383+ redirect_loc = next ((loc for loc in redirect_server .locations if loc .path == "/" ), None )
384+ if redirect_loc and redirect_loc .return_code == f"301 https://{ target_host } $request_uri" :
385+ break
386+ time .sleep (1 )
387+
388+ config_str = get_nginx_config_from_container (nginx_proxy_container [0 ])
389+ config = HttpBlock .parse (config_str )
390+ target_servers = [s for s in config .servers if target_host in s .server_names ]
391+ source_servers = [s for s in config .servers if source_host in s .server_names ]
392+
393+ assert any ("443" in s .listen for s in target_servers ), f"HTTPS target server not found. Config:\n { config_str } "
394+ assert len (source_servers ) == 1 , f"Expected one redirect source server. Config:\n { config_str } "
395+
396+ redirect_loc = next ((loc for loc in source_servers [0 ].locations if loc .path == "/" ), None )
397+ assert redirect_loc is not None , f"Redirect location not found. Config:\n { config_str } "
398+ assert redirect_loc .return_code == f"301 https://{ target_host } $request_uri"
399+ finally :
400+ if backend :
401+ stop_backend (backend )
402+
403+
355404@pytest .mark .parametrize ("backend_type" , ["container" , "service" ])
356405def test_webserver_add_two_containers_with_same_virtual_host_integration (
357406 nginx_proxy_container ,
0 commit comments