Port number getting stripped out of URL

nishantsingh

I have an django based website that's presented through gunicorn with nginx as reverse proxy. It's on port 81.The relevant portion of the configuration file looks like this:

upstream elearning_server {
    server localhost:8000;
}

server {
    listen          81;
......

If you go to:

http://webaddress:81 

the first time after you log in, it removes the port number and fails to connect to the website. If you then put the port number back into the url it works fine.

Has anyone got any suggestions of what I can try to fix this problem.

user3580562

What is happening is that your web server, as part of the login process is 'redirecting' your browser to a different web address. The problem is that the web address your browser is being redirected to doesn't exist, because it is being redirected to the wrong web address. When you modify the web address, you are correcting this error.

Obviously the solution is to correct this problem in the code, so you are sent straight to the correct web address without you needing to correct this.

The solution depends on your code. It is worth looking at it with the following in mind.

Is there something like:

return HttpResponseRedirect('http://website/dir/')

in your code somewhere? This would need to be altered to include the port number, i.e

return HttpResponseRedirect('http://website:81/dir/')

Or, even better,

return HttpResponseRedirect('/dir/')

(This will mean that it won't matter what port the server is on, because the redirect is 'relative'. This would be the usual way to code this sort of thing.)

If a quick perusal of the source doesn't cast any light, I would suggest that the next step would be to look in the access logs (and maybe error logs) from the web server, and look for '3xx' type messages, probably '301' and '302' messages, and this may give you some clue as to what is happening, and where in the code.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JQuery Data attributes getting stripped out in Kohana ajax

From Dev

Relative path to documents, passed from href to Javascript function, getting back slashes and period stripped out

From Dev

html tags are getting stripped out on storing to database, wordpress custom post type, editor

From Dev

Remove port number in image url?

From Dev

Getting images URL out of JSON

From Dev

Trouble getting variables out of the URL

From Dev

Figure out Rsyslog listening port number

From Dev

Redirect traffic to a domain with a port number without showing the port number in the URL

From Dev

Getting port from URL string using Javascript

From Dev

Nginx remove port number :8080 in the url

From Dev

forward the domain and remove the port number from the URL

From Dev

HTTPS url with port number not working on iOS

From Dev

Validate URL with valid port number and query string

From Dev

Get URL and port number from view

From Dev

Regex optionally match port number in url

From Dev

Nginx remove port number :8080 in the url

From Dev

Android - Forming an URL object specifying a port number

From Dev

How to connect url with port number in java with Jsoup?

From Dev

nmap or ping a url with embedded port number?

From Dev

mandrill template '@' stripped out from email address

From Dev

VLAN tag stripped out by linux box

From Dev

WebdriverIO - characters being stripped out of string

From Dev

How to find out which Port number a process is using

From Dev

Vertx/Hazelcast: How to find out current port number of cluster member?

From Dev

Getting wrong ip address and port number from recvfrom

From Dev

How to extract number out of url string ruby

From Dev

Trying to get number out of array getting NaN error

From Dev

increment a number with out getting rid of leading zeroes jquery

From Dev

How to multiply a large number in sql with out getting a "overflow error " error

Related Related

  1. 1

    JQuery Data attributes getting stripped out in Kohana ajax

  2. 2

    Relative path to documents, passed from href to Javascript function, getting back slashes and period stripped out

  3. 3

    html tags are getting stripped out on storing to database, wordpress custom post type, editor

  4. 4

    Remove port number in image url?

  5. 5

    Getting images URL out of JSON

  6. 6

    Trouble getting variables out of the URL

  7. 7

    Figure out Rsyslog listening port number

  8. 8

    Redirect traffic to a domain with a port number without showing the port number in the URL

  9. 9

    Getting port from URL string using Javascript

  10. 10

    Nginx remove port number :8080 in the url

  11. 11

    forward the domain and remove the port number from the URL

  12. 12

    HTTPS url with port number not working on iOS

  13. 13

    Validate URL with valid port number and query string

  14. 14

    Get URL and port number from view

  15. 15

    Regex optionally match port number in url

  16. 16

    Nginx remove port number :8080 in the url

  17. 17

    Android - Forming an URL object specifying a port number

  18. 18

    How to connect url with port number in java with Jsoup?

  19. 19

    nmap or ping a url with embedded port number?

  20. 20

    mandrill template '@' stripped out from email address

  21. 21

    VLAN tag stripped out by linux box

  22. 22

    WebdriverIO - characters being stripped out of string

  23. 23

    How to find out which Port number a process is using

  24. 24

    Vertx/Hazelcast: How to find out current port number of cluster member?

  25. 25

    Getting wrong ip address and port number from recvfrom

  26. 26

    How to extract number out of url string ruby

  27. 27

    Trying to get number out of array getting NaN error

  28. 28

    increment a number with out getting rid of leading zeroes jquery

  29. 29

    How to multiply a large number in sql with out getting a "overflow error " error

HotTag

Archive