Welcome! Log In Create A New Profile

Advanced

Getting an HTTP code 302 when I specify 301

Posted by Gibson, Brian (IMS) 
Gibson, Brian (IMS)
Getting an HTTP code 302 when I specify 301
March 20, 2017 06:20PM
I'm running haproxy 1.7.2 on my development server, and I have this code in to redirect traffic to https

http-request redirect code 301 scheme https if !{ ssl_fc }

The redirect works, but it's generating http code 302 not 301. At least that's what curl is telling me.

curl -I -L http://devurl/
HTTP/1.1 302 Found
Date: Mon, 20 Mar 2017 17:08:05 GMT
Server: Apache/2.4.25 (Unix) OpenSSL/1.0.2k-fips PHP/5.6.30
Location: https://devurl/
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 200 OK
Date: Mon, 20 Mar 2017 17:08:06 GMT
Server: Apache/2.4.25 (Unix) OpenSSL/1.0.2k-fips PHP/5.6.30
Vary: Accept-Encoding
Last-Modified: Mon, 20 Mar 2017 16:06:58 GMT
Content-Type: text/html
Content-Length: 188
Accept-Ranges: bytes
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15768000;includeSubDomains

________________________________

Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are not the addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender of the error.
Cyril Bonté
Re: Getting an HTTP code 302 when I specify 301
March 20, 2017 06:50PM
Hi,

Le 20/03/2017 à 18:17, Gibson, Brian (IMS) a écrit :
> I'm running haproxy 1.7.2 on my development server, and I have this code in to redirect traffic to https
>
> http-request redirect code 301 scheme https if !{ ssl_fc }
>
> The redirect works, but it's generating http code 302 not 301. At least that's what curl is telling me.
>
> curl -I -L http://devurl/
> HTTP/1.1 302 Found
> Date: Mon, 20 Mar 2017 17:08:05 GMT
> Server: Apache/2.4.25 (Unix) OpenSSL/1.0.2k-fips PHP/5.6.30

Here, your redirection is not done by haproxy but by your apache instance.
Without more details about your configuration, it will be difficult to
say what's going wrong in it. It's even possible that the request
doesn't go through haproxy but goes directly to the apache server.

Do you have enabled logs in haproxy ? Did you have a look at them ?

Please provide your configuration without sensitive data.


> Location: https://devurl/
> Content-Type: text/html; charset=iso-8859-1
>
> HTTP/1.1 200 OK
> Date: Mon, 20 Mar 2017 17:08:06 GMT
> Server: Apache/2.4.25 (Unix) OpenSSL/1.0.2k-fips PHP/5.6.30
> Vary: Accept-Encoding
> Last-Modified: Mon, 20 Mar 2017 16:06:58 GMT
> Content-Type: text/html
> Content-Length: 188
> Accept-Ranges: bytes
> X-Frame-Options: SAMEORIGIN
> Strict-Transport-Security: max-age=15768000;includeSubDomains
>
> ________________________________
>
> Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are not the addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender of the error.
>


--
Cyril Bonté
Gibson, Brian (IMS)
RE: Getting an HTTP code 302 when I specify 301
March 20, 2017 06:50PM
Actually I am sorry for my mistake, this one development resource does not use the haproxy DOH I should have done a little more investigation before I contacted this list. My haproxy is redirecting properly but a separate webserver is not. Sorry!

-----Original Message-----
From: Cyril Bonté [mailto:[email protected]]
Sent: Monday, March 20, 2017 1:44 PM
To: Gibson, Brian (IMS) <[email protected]>
Cc: haproxy@formilux.org
Subject: Re: Getting an HTTP code 302 when I specify 301

Hi,

Le 20/03/2017 à 18:17, Gibson, Brian (IMS) a écrit :
> I'm running haproxy 1.7.2 on my development server, and I have this
> code in to redirect traffic to https
>
> http-request redirect code 301 scheme https if !{ ssl_fc }
>
> The redirect works, but it's generating http code 302 not 301. At least that's what curl is telling me.
>
> curl -I -L http://devurl/
> HTTP/1.1 302 Found
> Date: Mon, 20 Mar 2017 17:08:05 GMT
> Server: Apache/2.4.25 (Unix) OpenSSL/1.0.2k-fips PHP/5.6.30

Here, your redirection is not done by haproxy but by your apache instance.
Without more details about your configuration, it will be difficult to say what's going wrong in it. It's even possible that the request doesn't go through haproxy but goes directly to the apache server.

Do you have enabled logs in haproxy ? Did you have a look at them ?

Please provide your configuration without sensitive data.


> Location: https://devurl/
> Content-Type: text/html; charset=iso-8859-1
>
> HTTP/1.1 200 OK
> Date: Mon, 20 Mar 2017 17:08:06 GMT
> Server: Apache/2.4.25 (Unix) OpenSSL/1.0.2k-fips PHP/5.6.30
> Vary: Accept-Encoding
> Last-Modified: Mon, 20 Mar 2017 16:06:58 GMT
> Content-Type: text/html
> Content-Length: 188
> Accept-Ranges: bytes
> X-Frame-Options: SAMEORIGIN
> Strict-Transport-Security: max-age=15768000;includeSubDomains
>
> ________________________________
>
> Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are not the addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender of the error.
>


--
Cyril Bonté

________________________________

Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are not the addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender of the error.
Sorry, only registered users may post in this forum.

Click here to login