Skip to content

Instantly share code, notes, and snippets.

@keithmorris
Forked from surjikal/nginx-s3.conf
Created October 17, 2017 16:18
Show Gist options
  • Select an option

  • Save keithmorris/a441038baf20c70eb8188db80c56b696 to your computer and use it in GitHub Desktop.

Select an option

Save keithmorris/a441038baf20c70eb8188db80c56b696 to your computer and use it in GitHub Desktop.

Revisions

  1. @surjikal surjikal revised this gist Jul 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nginx-s3.conf
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    server {
    listen 80;
    server_name *.dashboard.42debut.com;
    server_name *.foo.example.com;

    # We need this to resolve the host, because it's a wildcard.
    # This is google's DNS server.
  2. @surjikal surjikal created this gist Jul 7, 2013.
    39 changes: 39 additions & 0 deletions nginx-s3.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    server {
    listen 80;
    server_name *.dashboard.42debut.com;

    # We need this to resolve the host, because it's a wildcard.
    # This is google's DNS server.
    resolver 8.8.8.8;

    include /etc/nginx/includes/proxy.conf;

    # Don't show s3 errors
    proxy_intercept_errors on;
    error_page 403 404 500 502 503 @s3error;

    # Setup basic auth
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/conf/htpasswd.$host;

    error_page 403 404 500 502 503 @s3error;

    # Setup basic auth
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/conf/htpasswd.$host;

    # S3 derps if you send it the basic auth header
    proxy_set_header Authorization "";

    location ~ ^/assets/(.*)$ {
    proxy_pass http://$host.s3.amazonaws.com/assets/$1;
    }

    location / {
    proxy_pass http://$host.s3.amazonaws.com/index.html;
    }

    location @s3error {
    internal;
    }
    }