The request URL with the port, But response the next url without the port #8685
              
                
                  
                  
                    Answered
                  
                  by
                    lovelydinosaur
                  
              
          
                  
                    
                      rikeitou-0191632
                    
                  
                
                  asked this question in
                General
              
            -
        Request URL: http://xxx.xxx.xxx.xxx:81/aaa Response content: 
{
  "next": "http://xxx.xxx.xxx.xxx/aaa",
  "previous": "http://xxx.xxx.xxx.xxx/aaa",
  "current": "http://xxx.xxx.xxx.xxx/aaa"
}
Nginx upstream django_server {
    server django:8001;
}
server {
    listen       81;
    location /aaa {
         proxy_pass http://django_server;
         ...
    }
     | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            lovelydinosaur
          
      
      
        Oct 7, 2022 
      
    
    Replies: 1 comment 1 reply
-
| 
         To debug this you'd need to dig into Django's  I'd start by trying some debugging like... print(request.build_absolute_uri("/redirect"))   # Check if build_redirect_uri is including the port or not.
print(request.get_host())  # Show what host:port is being used for the absolute URIs.
print(request.META)  # Show the raw WSGI input to the request, which could help us dig out any misconfiguration issues.Relevant bits of Django source code...  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
      Answer selected by
        lovelydinosaur
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
To debug this you'd need to dig into Django's
request.build_absolute_uri()and figure out what's going wrong. Possibly some misconfiguration.I'd start by trying some debugging like...
Relevant bits of Django source code...
Http.build_absolute_uri()Http.get_host()