I had got a solution to my issue.
What I wanted to setup was an nginx reverse proxy, so that:
- it will receive requests from the client
- replace the host part in that URL with another CDN I wanted to access
- forward this request to the CDN, through a forward proxy.
I had to access the CDN through the nginx server, because I wanted to cache the contents served, and thus reduce the number of hits to CDN.
Well, the solution I got is this:
myconfig.conf
server {
listen 8000;
server_name my-domain-name.com;
location / {
rewrite ^(.*)$ "://the-cdn-domain-name.com$1";
rewrite ^(.*)$ "https$1" break;
proxy_pass http://X.X.X.X:1234; # this is my forward proxy IP
}
}
This is what you have to include in the conf.d directory.
What I wanted to setup was an nginx reverse proxy, so that:
- it will receive requests from the client
- replace the host part in that URL with another CDN I wanted to access
- forward this request to the CDN, through a forward proxy.
I had to access the CDN through the nginx server, because I wanted to cache the contents served, and thus reduce the number of hits to CDN.
Well, the solution I got is this:
myconfig.conf
server {
listen 8000;
server_name my-domain-name.com;
location / {
rewrite ^(.*)$ "://the-cdn-domain-name.com$1";
rewrite ^(.*)$ "https$1" break;
proxy_pass http://X.X.X.X:1234; # this is my forward proxy IP
}
}
This is what you have to include in the conf.d directory.