Advertisement
Guest User

Back_Nginx

a guest
Sep 17th, 2019
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.97 KB | None | 0 0
  1. server {
  2.     listen      80;
  3.     server_name kobo.example.com kc.docker.internal;
  4.  
  5.     access_log  /var/log/nginx/kobocat.access.log with_host;
  6.     error_log   /var/log/nginx/kobocat.error.log;
  7.  
  8.     include /etc/nginx/include.server_directive_common.conf;
  9.  
  10.     location / {
  11.         # Proxy through uWSGI.
  12.         include /tmp/nginx_templates_activated/kobocat_uwsgi_pass.conf;
  13.  
  14.         # Debug proxying directly to container.
  15.  
  16.     }
  17.  
  18.     location /static {
  19.         alias /srv/www/kobocat;
  20.     }
  21.  
  22.     # media files
  23.     location /protected/ {
  24.         internal;
  25.         alias /media/;
  26.     }
  27.  
  28.     location ~ ^/protected-s3/(.*)$ {
  29.         # Allow internal requests only, i.e. return a 404 to any client who
  30.         # tries to access this location directly
  31.         internal;
  32.         # Name resolution won't work at all without specifying a resolver here.
  33.         # Configuring a validity period is useful for overriding Amazon's very
  34.         # short (5-second?) TTLs.
  35.         resolver 8.8.8.8 8.8.4.4 valid=300s;
  36.         resolver_timeout 10s;
  37. # Everything that S3 needs is in the URL; don't pass any headers or
  38.         # body content that the client may have sent
  39.         proxy_pass_request_body off;
  40.         proxy_pass_request_headers off;
  41.  
  42.         # Stream the response to the client instead of trying to read it all at
  43.         # once, which would potentially use disk space
  44.         proxy_buffering off;
  45.  
  46.         # Don't leak S3 headers to the client. List retrieved from:
  47.         # https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html
  48.         proxy_hide_header x-amz-delete-marker;
  49.         proxy_hide_header x-amz-id-2;
  50.         proxy_hide_header x-amz-request-id;
  51.         proxy_hide_header x-amz-version-id;
  52.  
  53.         # S3 will complain if `$1` contains non-encoded special characters.
  54.         # KoBoCAT must encode twice to make sure `$1` is still encoded after
  55.         # NGINX's automatic URL decoding.
  56.         proxy_pass $1;
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement