Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Im using Nginx front-end server in front of glassfish app. server. I uploaded my static contents to Amazon S3. I need to implement passing static request to Amazon's URL. I did a conf file like below.

    location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
    access_log off;
    expires max;    
    proxy_pass http://s3-eu-west-1.amazonaws.com/usta/html/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


But with reqular expression, i couldnt proxy request to Amazon s3 URL, how can i implement this idea?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

This would be an inefficient solution because all requests for static content would still be going to your Nginx server, costing you unnecessary bandwidth and CPU.

The better solution is to store and reference your static content as static.example.com, and then associate your domain name with your S3 bucket. Then your static content could be efficiently served directly from S3, while still appearing to be hosted at your domain name.

Also see this related question:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.