Answer the question
In order to leave comments, you need to log in
How to proxy all HTTP requests through your server?
The task is this: my site has an nginx server, let's call it mysite , and there is another server that provides some HTTP API, let's call it httpapi . In order not to do CORS for other reasons, you need to proxy all HTTP requests from the client to httpapi through mysite .
For example it will look like this:
// get products API
POST https://httpapi.com/get_products
fetch('/proxy/get_products', {
method: "POST",
body: params
};
Answer the question
In order to leave comments, you need to log in
server {
listen 80;
server_name my.proxy.ru;
location /proxy {
rewrite ^/proxy/(.*) /$1;
proxy_pass http://kuda.nado.ru;
}
}
As a result, we could not configure mod_proxy due to cpanel features, but to be honest, we didn’t really try.
Went the other way and I made a simple php script that makes a proxy. If it will be useful to someone - posted it on github:
https://github.com/pinebit/http-request-proxy
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question