Welcome! Log In Create A New Profile

Advanced

Re: proxy only certain assets based on host header?

Maxim Dounin
May 24, 2013 09:08AM
Hello!

On Thu, May 23, 2013 at 09:07:21PM -0400, amagad wrote:

> We're trying to proxy only certain assets like png|jpg|css only when the
> host header is a certain DNS name. I tried to do this in the proxy.conf file
> using something the example below but it doesnt like the if statement. Is
> there a way to have nginx do what I am looking for?
>
>
> if ($http_host = dnsname.com) {
> location ~ ^/(stylesheets|images|javascripts|tools|flash|components)/ {
> proxy_pass http://assethost
> }
> }

Yes, sure. Use separate server{} block for a domain name you want
to be handled specially, e.g.:

server {
server_name foo.example.com;

location / {
# just serve anything as static
}
}

server {
server_name bar.example.com;

location / {
# server anything as static...
}

location /images/ {
# ... but proxy images to a backend
proxy_pass http://backend;
}
}

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

proxy only certain assets based on host header?

amagad May 23, 2013 09:07PM

Re: proxy only certain assets based on host header?

António P. P. Almeida May 24, 2013 04:46AM

Re: proxy only certain assets based on host header?

Maxim Dounin May 24, 2013 09:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready