How to Return 200 OK for certain IPs


#1

I need to return a 200 OK to certain IPs which are getting a 301. The details are:

“GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.0

I need to return a 200 instead of the 301 and 439. Can someone please help?


(Rafael dos Santos Silva) #2

I think the 439 is the response size.

Now about the 301 can you explain why? Maybe we can workaround this.


#3

My instance is on Google Compute like yours, and as I am setting up a load balancer, Google sends health check requests to check if the instance is healthy and whether to route traffic to that instance or not.

Unfortunately, it is getting a 301 back and returning my instance as ‘unhealthy’. The details for the health check are:

Path: /
Protocol: HTTPS
Port: 443
Interval: 5 seconds
Timeout: 5 seconds
Unhealthy threshold: 2 consecutive failures
Healthy threshold: 2 consecutive successes

Any suggestions?


(Rafael dos Santos Silva) #4

Can you point it to https://try.discourse.org/srv/status ?


#5

Point the health check?

I can only point to a path eg. / or /xyz and not to a domain.
I can edit the host header though.


(Rafael dos Santos Silva) #6

Point it to the path /srv/status

The try url was just an example :smile:


#7

Unfortunately, still getting the same 301 :frowning:

[30/Jul/2016:17:14:00 +0000] 130.211.1.78 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:02 +0000] 130.211.1.206 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:03 +0000] 130.211.0.235 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:05 +0000] 130.211.1.78 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:07 +0000] 130.211.1.206 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:08 +0000] 130.211.0.235 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:10 +0000] 130.211.1.78 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:12 +0000] 130.211.1.206 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:13 +0000] 130.211.0.235 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”
[30/Jul/2016:17:14:15 +0000] 130.211.1.78 “GET / HTTP/1.1” “GoogleHC/1.0” “-” 301 439 “-” - 0.000 “-”


(Rafael dos Santos Silva) #8

It still isn’t using the path…


#9

Its using it now, but still the 301:

[30/Jul/2016:17:23:01 +0000] 130.211.1.78 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:04 +0000] 130.211.1.206 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:06 +0000] 130.211.0.235 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:06 +0000] 130.211.1.78 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:09 +0000] 130.211.1.206 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:11 +0000] 130.211.0.235 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:11 +0000] 130.211.1.78 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:14 +0000] 130.211.1.206 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:16 +0000] 130.211.0.235 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:16 +0000] 130.211.1.78 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:19 +0000] 130.211.1.206 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:21 +0000] 130.211.0.235 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:21 +0000] 130.211.1.78 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”
[30/Jul/2016:17:23:24 +0000] 130.211.1.206 “GET /srv/status HTTP/1.1” “GoogleHC/1.0” “-” 301 449 “-” - 0.000 “-”


(Rafael dos Santos Silva) #10

You are using HTTPS so it 301 http://example.com/srv/status to https://example.com/srv/status. You need to ping on port 443.


#11

I have specified the port as 443 and the protocol as HTTPS in the health check, but I think somehow it is still using http. Im going to try and manually change the port and see if it helps.


#12

@Falco I reset the health check and it returns instance as healthy and the load balancer is working fine :slight_smile:

That’s the good news. The strange thing is that it is still getting the 301 in the logs but still returning it as healthy. Not that I mind, but I don’t get why it should :confused:

Thank you for your help! Much appreciated! One last question - I am using Google’s CDN. Do I need to set anything in app.yml for the cdn path or just let Google serve content automatically? Because Google does not specify a cdn path.