|
| 1 | +# |
| 2 | +# This file is responsible for the site which serves the main releases from codeorigin. By default, |
| 3 | +# it generates a site that operates in "break glass" emergency mode. All requests are served, |
| 4 | +# regardless of where they come from. |
| 5 | +# |
| 6 | +# In production, the CDN should add a private header to origin fetches. All requests which do not |
| 7 | +# include the correct header should be bounced via 301 redirect back to the CDN. This ensures that |
| 8 | +# even if a client attempts to link to codeorigin, it will still be served from the CDN. The end |
| 9 | +# result should be that codeorigin is only reachable for origin pulls from the CDN, decreasing its |
| 10 | +# load and reducing the attack surface for DDOSs. |
| 11 | +# |
| 12 | +# Configuration information is in the README.md file. |
| 13 | +# |
| 14 | + |
| 15 | +# Increase map_hash_bucket_size to accommodate longer CDN tokens |
| 16 | +map_hash_bucket_size 128; |
| 17 | + |
| 18 | +# Do not change the following lines. The Dockerfile will set the access key and remove the comment |
| 19 | +# at build time if the correct environment variable is set. |
| 20 | +##ACTIVATE-XCDNACCESS##map $http_x_cdn_access $reroute_to_cdn { default '1'; CDN_ACCESS_KEY_PLACEHOLDER '0'; } |
| 21 | + |
| 22 | +server { |
| 23 | + listen 80; |
| 24 | + listen [::]:80; |
| 25 | + server_name localhost; |
| 26 | + |
| 27 | + access_log /var/log/nginx/host.access.log main; |
| 28 | + |
| 29 | + location / { |
| 30 | + root /usr/share/nginx/html; |
| 31 | + index index.html index.htm; |
| 32 | + |
| 33 | + # Do not change the following line. The Dockerfile will set the access key and remove the |
| 34 | + # comment at build time if the correct environment variable is set. |
| 35 | + ##ACTIVATE-XCDNACCESS##if ($reroute_to_cdn) { return 301 https://code2.jquery.com$uri; } |
| 36 | + |
| 37 | + } |
| 38 | + |
| 39 | + # PHP configuration for purge.php |
| 40 | + |
| 41 | + location ~ \.php$ { |
| 42 | + root /usr/share/nginx/html; |
| 43 | + fastcgi_pass 127.0.0.1:9000; |
| 44 | + fastcgi_index index.php; |
| 45 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 46 | + include fastcgi_params; |
| 47 | + } |
| 48 | + |
| 49 | + # Redirect requests to the root to the release viewer |
| 50 | + |
| 51 | + location ~ ^/(?:/)?$ { |
| 52 | + expires off; |
| 53 | + gzip on; |
| 54 | + return 301 https://releases.jquery.com; |
| 55 | + } |
| 56 | + |
| 57 | + # Redirect requests to paths known to be non-release files (e.g., git versions and their assets) |
| 58 | + # to the viewer. Jenkins needs access to the host that delivers these files, and codeorigin is |
| 59 | + # intended to be more tightly managed via github repo. |
| 60 | + |
| 61 | + # Redirect to releases.jquery.com/ |
| 62 | + |
| 63 | + location ~ ^/git(?:/(.*))? { |
| 64 | + expires off; |
| 65 | + gzip on; |
| 66 | + return 301 https://releases.jquery.com$request_uri; |
| 67 | + } |
| 68 | + |
| 69 | + # Redirect specific project pages to releases.jquery.com |
| 70 | + location ~ ^/jquery(?:/)?$ { |
| 71 | + expires off; |
| 72 | + gzip on; |
| 73 | + return 301 https://releases.jquery.com/jquery/; |
| 74 | + } |
| 75 | + |
| 76 | + location ~ ^/ui(?:/)?$ { |
| 77 | + expires off; |
| 78 | + gzip on; |
| 79 | + return 301 https://releases.jquery.com/ui/; |
| 80 | + } |
| 81 | + |
| 82 | + location ~ ^/mobile(?:/)?$ { |
| 83 | + expires off; |
| 84 | + gzip on; |
| 85 | + return 301 https://releases.jquery.com/mobile/; |
| 86 | + } |
| 87 | + |
| 88 | + location ~ ^/color(?:/)?$ { |
| 89 | + expires off; |
| 90 | + gzip on; |
| 91 | + return 301 https://releases.jquery.com/color/; |
| 92 | + } |
| 93 | + |
| 94 | + location ~ ^/qunit(?:/)?$ { |
| 95 | + expires off; |
| 96 | + gzip on; |
| 97 | + return 301 https://releases.jquery.com/qunit/; |
| 98 | + } |
| 99 | + |
| 100 | + location ~ ^/pep(?:/)?$ { |
| 101 | + expires off; |
| 102 | + gzip on; |
| 103 | + return 301 https://releases.jquery.com/pep/; |
| 104 | + } |
| 105 | + |
| 106 | + # Redirect to releases.jquery.com/git/ |
| 107 | + |
| 108 | + location ~* -git\.(js|min.js|slim.js|slim.min.js|css)$ { |
| 109 | + expires off; |
| 110 | + gzip on; |
| 111 | + return 301 https://releases.jquery.com/git$request_uri; |
| 112 | + } |
| 113 | + |
| 114 | + location ^~ /mobile/git/ { |
| 115 | + expires off; |
| 116 | + gzip on; |
| 117 | + return 301 https://releases.jquery.com/git$request_uri; |
| 118 | + } |
| 119 | + |
| 120 | + # Redirect some known legacy URLs that may still point to code.jquery.com. This list is a |
| 121 | + # workaround, and should not need to be expanded. |
| 122 | + |
| 123 | + rewrite ^/ui/images/ui-icons_cc0000_256x240\.png$ https://releases.jquery.com/git/ui/images/ui-icons_cc0000_256x240.png permanent; |
| 124 | + rewrite ^/ui/images/ui-icons_777777_256x240\.png$ https://releases.jquery.com/git/ui/images/ui-icons_777777_256x240.png permanent; |
| 125 | + rewrite ^/ui/images/ui-icons_777620_256x240\.png$ https://releases.jquery.com/git/ui/images/ui-icons_777620_256x240.png permanent; |
| 126 | + rewrite ^/ui/images/ui-icons_555555_256x240\.png$ https://releases.jquery.com/git/ui/images/ui-icons_555555_256x240.png permanent; |
| 127 | + rewrite ^/ui/images/ui-icons_444444_256x240\.png$ https://releases.jquery.com/git/ui/images/ui-icons_444444_256x240.png permanent; |
| 128 | + rewrite ^/ui/images/ui-bg_flat_0_aaaaaa_40x100\.png$ https://releases.jquery.com/git/ui/images/ui-bg_flat_0_aaaaaa_40x100.png permanent; |
| 129 | + rewrite ^/ui/images/ui-icons_ffffff_256x240\.png$ https://releases.jquery.com/git/ui/images/ui-icons_ffffff_256x240.png permanent; |
| 130 | + rewrite ^/ui/_images/images/ui-icons_cc0000_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_cc0000_256x240.png permanent; |
| 131 | + rewrite ^/ui/_images/images/ui-bg_highlight-soft_75_cccccc_1x100\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_highlight-soft_75_cccccc_1x100.png permanent; |
| 132 | + rewrite ^/ui/_images/images/ui-icons_2e83ff_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_2e83ff_256x240.png permanent; |
| 133 | + rewrite ^/ui/_images/images/ui-bg_flat_75_ffffff_40x100\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_flat_75_ffffff_40x100.png permanent; |
| 134 | + rewrite ^/ui/_images/images/ui-bg_glass_95_fef1ec_1x400\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_glass_95_fef1ec_1x400.png permanent; |
| 135 | + rewrite ^/ui/_images/images/ui-icons_777777_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_777777_256x240.png permanent; |
| 136 | + rewrite ^/ui/_images/images/ui-bg_glass_65_ffffff_1x400\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_glass_65_ffffff_1x400.png permanent; |
| 137 | + rewrite ^/ui/_images/images/ui-icons_777620_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_777620_256x240.png permanent; |
| 138 | + rewrite ^/ui/_images/images/ui-icons_555555_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_555555_256x240.png permanent; |
| 139 | + rewrite ^/ui/_images/images/ui-bg_glass_75_e6e6e6_1x400\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_glass_75_e6e6e6_1x400.png permanent; |
| 140 | + rewrite ^/ui/_images/images/ui-icons_222222_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_222222_256x240.png permanent; |
| 141 | + rewrite ^/ui/_images/images/ui-icons_888888_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_888888_256x240.png permanent; |
| 142 | + rewrite ^/ui/_images/images/ui-icons_444444_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_444444_256x240.png permanent; |
| 143 | + rewrite ^/ui/_images/images/ui-icons_cd0a0a_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_cd0a0a_256x240.png permanent; |
| 144 | + rewrite ^/ui/_images/images/ui-bg_glass_55_fbf9ee_1x400\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_glass_55_fbf9ee_1x400.png permanent; |
| 145 | + rewrite ^/ui/_images/images/ui-icons_454545_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_454545_256x240.png permanent; |
| 146 | + rewrite ^/ui/_images/images/ui-bg_glass_75_dadada_1x400\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_glass_75_dadada_1x400.png permanent; |
| 147 | + rewrite ^/ui/_images/images/ui-bg_flat_0_aaaaaa_40x100\.png$ https://releases.jquery.com/git/ui/_images/images/ui-bg_flat_0_aaaaaa_40x100.png permanent; |
| 148 | + rewrite ^/ui/_images/images/ui-icons_ffffff_256x240\.png$ https://releases.jquery.com/git/ui/_images/images/ui-icons_ffffff_256x240.png permanent; |
| 149 | + rewrite ^/ui/_images/ui-bg_highlight-soft_75_cccccc_1x100\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_highlight-soft_75_cccccc_1x100.png permanent; |
| 150 | + rewrite ^/ui/_images/ui-icons_2e83ff_256x240\.png$ https://releases.jquery.com/git/ui/_images/ui-icons_2e83ff_256x240.png permanent; |
| 151 | + rewrite ^/ui/_images/ui-bg_flat_75_ffffff_40x100\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_flat_75_ffffff_40x100.png permanent; |
| 152 | + rewrite ^/ui/_images/ui-bg_glass_95_fef1ec_1x400\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_glass_95_fef1ec_1x400.png permanent; |
| 153 | + rewrite ^/ui/_images/ui-bg_glass_65_ffffff_1x400\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_glass_65_ffffff_1x400.png permanent; |
| 154 | + rewrite ^/ui/_images/ui-bg_glass_75_e6e6e6_1x400\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_glass_75_e6e6e6_1x400.png permanent; |
| 155 | + rewrite ^/ui/_images/ui-icons_222222_256x240\.png$ https://releases.jquery.com/git/ui/_images/ui-icons_222222_256x240.png permanent; |
| 156 | + rewrite ^/ui/_images/ui-icons_888888_256x240\.png$ https://releases.jquery.com/git/ui/_images/ui-icons_888888_256x240.png permanent; |
| 157 | + rewrite ^/ui/_images/ui-icons_cd0a0a_256x240\.png$ https://releases.jquery.com/git/ui/_images/ui-icons_cd0a0a_256x240.png permanent; |
| 158 | + rewrite ^/ui/_images/ui-bg_glass_55_fbf9ee_1x400\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_glass_55_fbf9ee_1x400.png permanent; |
| 159 | + rewrite ^/ui/_images/ui-icons_454545_256x240\.png$ https://releases.jquery.com/git/ui/_images/ui-icons_454545_256x240.png permanent; |
| 160 | + rewrite ^/ui/_images/ui-bg_glass_75_dadada_1x400\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_glass_75_dadada_1x400.png permanent; |
| 161 | + rewrite ^/ui/_images/ui-bg_flat_0_aaaaaa_40x100\.png$ https://releases.jquery.com/git/ui/_images/ui-bg_flat_0_aaaaaa_40x100.png permanent; |
| 162 | + |
| 163 | + #error_page 404 /404.html; |
| 164 | + |
| 165 | + # redirect server error pages to the static page /50x.html |
| 166 | + # |
| 167 | + error_page 500 502 503 504 /50x.html; |
| 168 | + location = /50x.html { |
| 169 | + root /usr/share/nginx/html; |
| 170 | + } |
| 171 | +} |
| 172 | + |
| 173 | +# vim: ts=2 sw=2 et |
0 commit comments