Caching a subdomain redirect

Hello, I made an api subdomain, connected it to Cloudflare, but when clicking on it, I will be redirected to a cached page. The technical support of my hosting answered me, attached the result:

$ curl -IL http://api.rus-standart.xyz
HTTP/1.1 301 Moved Permanently
Date: Sun, 25 Feb 2024 12:46:22 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Sun, 25 Feb 2024 13:46:22 GMT
Location: https://api.rus-standart.xyz/
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=PLF0%2F7S0ir9gEpK5%2BsW6AjXhVF2ZboZLEDud%2Bz%2BmcHnU5Q8evME35yACl3CCyVwLk2SeI9IGdrmzXULqjagWTJBgvfLcwqvJlH0PpxIvyoROdwFTPQRbvqHI%2FWsH3xrPRHs05YlKSA%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 85b00cfee8316fb4-CDG
alt-svc: h3=":443"; ma=86400

HTTP/2 302 
date: Sun, 25 Feb 2024 12:46:22 GMT
content-type: text/html
location: https://api.rus-standart.xyz/index.html
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=8JeV0CpgCMEJgXSKNI7myq4FHDdcAZHic643Fw375PtdMIM9g32E8TObqglEtDocnV054U0py%2FcyJioJuIIn0mmx6UMD7UbUkVaYw99mTwgRIwVt7ic40hL8v1CkNdq%2FWZ%2Fd8P7%2BaQ%3D%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 85b00d006ecf1c08-AMS
alt-svc: h3=":443"; ma=86400

HTTP/2 200 
date: Sun, 25 Feb 2024 12:46:23 GMT
content-type: text/html
last-modified: Mon, 19 Feb 2024 10:30:17 GMT
accept-ranges: bytes
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Tl824esDyiadBI%2B6dVwXxUSRvz1Lo21pj1%2F1EUfAknmkvK4XjlAbz3YzpS1ucjr6hVU3AnYbS04oYQ2cQYF%2FBEOZee3x1fviWTJiM%2BKzJDKZVA0sppPY6puUiz0VEUo0ib0DExMlUg%3D%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 85b00d0209111c08-AMS
alt-svc: h3=":443"; ma=86400

I was told that if I edit the hosts file on my computer, everything will be displayed correctly and the following response will come:

$ curl -IL http://api.rus-standart.xyz
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Sun, 25 Feb 2024 12:51:28 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.4.33

Tell me, is it possible to fix this?

For starters, is your server working on HTTPS? Your example only shows an HTTP URL.

1 Like

Yes, over HTTPS, automatic redirect to HTTPS

What’s the output of this command with the hosts file?

curl -I https://api.rus-standart.xyz
Date: Sun, 25 Feb 2024 18:05:58 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://api.rus-standart.xyz/index.html
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=1bY5Tes3ElQ9%2BdfVOZjxeHOytIfnMVSva4LXqAJURNdQbep0%2FT2emYMO0yTyTn7qOlrtY7Op1bwTGiibvryVChwH7q6KbbXYrQPlCKqozCFEv6BZOSVscpUi%2FQEDOh0fOtHVoJ75sdmmBNuQQ19VrLTBVg%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 85b1e1229b1567a2-SJC
alt-svc: h3=":443"; ma=86400

HTTP/1.1 200 OK
Date: Sun, 25 Feb 2024 18:05:58 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Last-Modified: Mon, 19 Feb 2024 10:30:17 GMT
Accept-Ranges: bytes
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Vr39c2gCPbfChVwuboGoEnfca76TxiMimSCJhw%2B8hgIOXGwmZMEiAlaekcOVHXgyMPnQ36swXG9%2B30pl5FSNx8%2F7%2B5LQVMRqhNR4t63MsIGsKrsDvZZq2PcIeruLZXeqpmL64lPo%2B89ooVkVekWLqCaCvQ%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 85b1e1279eb967a2-SJC
alt-svc: h3=":443"; ma=86400```

That is not with the hosts file as I mentioned.

If you edit the hosts file, you get the following response:

$ curl -IL http://api.rus-standart.xyz
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Sun, 25 Feb 2024 12:51:28 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.4.33

That is not the command I posted.

Anyhow, assuming your server IP address ends in 143, you do not have a valid SSL certificate on your server

$ curl -I https://api.rus-standart.xyz
curl: (60) SSL certificate problem: self signed certificate

You need to fix this first. Pause Cloudflare and make sure that the site loads fine on HTTPS. You may have to talk to your host

1 Like

I have an SSL certificate displayed

Sorry, everything is in Russian

You haven’t paused Cloudflare yet.

Do I need to disable Cloudflare?

Only pause.

Then will the real IP address of the machine be displayed?

Yes, but you need to do that to debug the issue.

Do you want to send the curl -I command https://api.rus-standart.xyz from your computer? Or what is it required for?

Well, alternatively, can you provide the information I asked earlier?

I’m sorry for the delay, I got this result:

This is not the output of curl.