Instead of showing the proxy’d url as part of my site, it’s just sending me to the proxy’d url. Here are the details:
I have a react app hosted on Netlify that has the https://gyfteo.com/ domain setup ( loving-payne-8c0665 is the Netlify name ). I want to proxy a wordpress blog ( https://blog.gyfteo.com/ ) to https://gyfteo.com/blog. The proxy seems to partially work, except when I go to https://gyfteo.com/blog, it’s just sending me to https://blog.gyfteo.com/ instead of showing the blog on https://gyfteo.com/blog.
I’m using a netlify.toml file and it is being processed when the react site is deployed to netlify. Here’s the file:
[[redirects]]
from = "/blog/*"
to = "https://blog.gyfteo.com/:splat"
status = 200
headers = {X-From = "Netlify"}
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
I had force = true in there but removed it in hopes that would do the trick, but no luck. Any help would be appreciated.
Hey @hrishikesh, thanks for the reply. The server is Netlify - any suggestions on what I can update in the netlify.toml file? Or is there another route to look into here?
x-redirect-by and x-turbo-charged-by show the source of the issue. The server is Netlify because you proxied the request. But the source of the redirect is not Netlify, it’s WordPress.
Hey @hrishikesh, right, ya, i’m trying to proxy a wordpress site to Coming Soon – Gyfteo Blog. I’m not following your responses on what the issue is. My understanding of setting up a proxy is that i can make another site show up as a subdirectory of my main domain. Do you know if there is anything I need to change in my netlify.toml file to make this work?
hey @fool, I think i’m saying it right when i say, yes, i want to proxy to another site. My main site is hosted on Netlify and I want to proxy another site to a sub-directory of my main domain. What is the correct configuration to do this?
Hi, @John_Goodman. The issue is that a proxy just returns the responses from the site you proxy to. The site you proxy to is sending the 302 and we just pass that 302 response along to the client. If you want to fix this, you need to change the behavior of the proxy target.
Here are some examples to clarify. Here is a HTTP response showing the status code returned and the location header (if there is one):
This is the same 302 coming directly from the proxy target.
This is why you get the 302 at Netlify. The 302 is coming from the proxy target itself. All Netlify does (all any proxy does) is just pass along the response of the proxy target to the HTTP client. If you don’t want the 302 sent you need to change that behavior at the proxy target (at blog.gyfteo.com).
If there are other questions about this, please let us know.
Ooooookkk, that explains it. I didn’t realize the site I was proxying had a redirect on. I turned it off and the proxy is working as expected. Thanks for your detailed explanation @luke