akamai-nginx
Version:
generate nginx config from akamai property
103 lines (70 loc) • 2.84 kB
Plain Text
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type text/html;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
lua_package_path "/usr/local/openresty/nginx/conf/lua/?.lua;;";
proxy_cache_path cache levels=1:2 keys_zone=akamai:100m inactive=60m;
proxy_cache_key "$scheme$request_method$host$request_uri";
proxy_store_access user:rw group:rw all:r;
server {
lua_code_cache off;
listen 80;
server_name localhost;
listen 443 http2 ssl;
ssl_certificate ssl/nginx.crt;
ssl_certificate_key ssl/nginx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
resolver 127.0.0.11 ipv6=off;
proxy_ssl_verify off;
proxy_ssl_server_name on;
proxy_set_header Host $http_host;
# pass real client ip to nginx akamai instance
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Akamai-Client-IP $remote_addr;
proxy_cache akamai;
# use the cache if there's a error on app server or it's updating from another request
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
# don't let two requests try to populate the cache at the same time
proxy_cache_lock on;
# allow cache bypass via qs or cookie
proxy_cache_bypass $cookie_nocache $arg_nocache;
# proxy to akamai container. the akamai container can modify cache related
# headers which will be respected here. setting cache parameters such as ttl
# in the akamai container cannot control the proxy_cache behavior.
proxy_pass $scheme://akamai;
proxy_pass_header X-Accel-Expires;
add_header X-Proxy-Cache $upstream_cache_status;
add_header X-Request-time $request_time;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types *;
}
location /info {
content_by_lua '
local info = require "info"
info()';
}
}
}