diff --git a/examples/cache.conf b/examples/cache.conf new file mode 100644 index 0000000000000000000000000000000000000000..e910a05854632c664308a82fe1775fda5578c406 --- /dev/null +++ b/examples/cache.conf @@ -0,0 +1,72 @@ +proxy_cache_path /data/nginx/tmpcache levels=2:2 keys_zone=two:10m loader_threshold=300 + loader_files=200 max_size=200m inactive=1m; + +server { + server_name cache.taohui.tech; + + root html/; + error_log logs/cacherr.log debug; + + location ~ /purge(/.*) { + proxy_cache_purge two $scheme$1; + } + + location /{ + #expires @20h30m; + #if_modified_since off; + proxy_cache two; + proxy_cache_valid 200 1m; + add_header X-Cache-Status $upstream_cache_status; + #proxy_cache_use_stale error timeout updating; + #proxy_cache_key $scheme$uri; + #proxy_cache_revalidate on; + #proxy_cache_background_update on; + #proxy_hide_header Set-Cookie; + #proxy_ignore_headers Set-Cookie; + + #proxy_force_ranges on; + + proxy_cache_key $scheme$uri; + proxy_pass http://localhost:8012; + } + + listen 443 ssl; # managed by Certbot + ssl_certificate examples/cert/a.crt; + ssl_certificate_key examples/cert/a.key; + #include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + #ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + + ssl_verify_client optional; + ssl_verify_depth 2; + #ssl_trusted_certificate examples/cert/ca.crt; + ssl_client_certificate examples/cert/ca.crt; + #ssl_client_certificate LetsEncryptAuthorityX3.crt; + + location /test { + default_type text/plain; + return 200 ' +ssl_client_escaped_cert: $ssl_client_escaped_cert +ssl_client_cert: $ssl_client_cert +ssl_client_raw_cert: $ssl_client_raw_cert +ssl_cipher: $ssl_cipher +ssl_ciphers: $ssl_ciphers +ssl_client_fingerprint: $ssl_client_fingerprint +ssl_client_i_dn: $ssl_client_i_dn +ssl_client_i_dn_legacy: $ssl_client_i_dn_legacy +ssl_client_s_dn: $ssl_client_s_dn +ssl_client_s_dn_legacy: $ssl_client_s_dn_legacy +ssl_client_serial: $ssl_client_serial +ssl_client_v_end: $ssl_client_v_end +ssl_client_v_remain: $ssl_client_v_remain +ssl_client_v_start: $ssl_client_v_start +ssl_client_verify: $ssl_client_verify +ssl_curves: $ssl_curves +ssl_protocol: $ssl_protocol +ssl_server_name: $ssl_server_name +ssl_session_id: $ssl_session_id +ssl_session_reused: $ssl_session_reused +'; + } + + listen 80; # managed by Certbot +} diff --git a/examples/grpc.conf b/examples/grpc.conf new file mode 100644 index 0000000000000000000000000000000000000000..734a92a12acff83473b0273113ec50d177eb0e29 --- /dev/null +++ b/examples/grpc.conf @@ -0,0 +1,15 @@ +server { + server_name http2.taohui.tech; + + root html; + location / { + grpc_pass localhost:50051; + } + + listen 4431 http2; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/http2.taohui.tech/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/http2.taohui.tech/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +} diff --git a/examples/http2.conf b/examples/http2.conf new file mode 100644 index 0000000000000000000000000000000000000000..b4d2fcb0258f3bbbbff25a279b98e1a80c13c718 --- /dev/null +++ b/examples/http2.conf @@ -0,0 +1,21 @@ +server { + server_name http2.taohui.tech; + + root html; + location / { + http2_push /mirror.txt; + http2_push /video.mp4; + } + + location /test { + add_header Link "; as=style; rel=preload"; + http2_push_preload on; + } + + listen 4430 ssl http2; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/http2.taohui.tech/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/http2.taohui.tech/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +} diff --git a/examples/memcached.conf b/examples/memcached.conf new file mode 100644 index 0000000000000000000000000000000000000000..4ec34178ca864015a0a48e719f3bb5b8b43adb81 --- /dev/null +++ b/examples/memcached.conf @@ -0,0 +1,11 @@ +server { + server_name memcached.taohui.tech; + #root html/; + default_type text/plain; + + location /get { + set $memcached_key "$arg_key"; + #memcached_gzip_flag 2; + memcached_pass localhost:11211; + } +} diff --git a/examples/nextups.conf b/examples/nextups.conf new file mode 100644 index 0000000000000000000000000000000000000000..535e6b0830c799e49540f386b5fc75cfe4b0efda --- /dev/null +++ b/examples/nextups.conf @@ -0,0 +1,37 @@ +upstream nextups { + server 127.0.0.1:8013; + server 127.0.0.1:8011; +} + +server { + server_name nextups.taohui.tech; + error_log logs/myerror.log debug; + #root html/; + default_type text/plain; + + error_page 500 /test1.txt; + + location / { + proxy_pass http://nextups; + } + + location /test { + } + + location /error { + proxy_pass http://nextups; + proxy_connect_timeout 1s; + proxy_next_upstream error; + } + + location /intercept { + proxy_intercept_errors on; + proxy_pass http://127.0.0.1:8013; + } + + location /httperr { + proxy_next_upstream http_500; + proxy_pass http://nextups; + } + +} diff --git a/examples/openfilecache.conf b/examples/openfilecache.conf new file mode 100644 index 0000000000000000000000000000000000000000..7de3421b5d151b5c93dec1f58ca6c78defbfeb35 --- /dev/null +++ b/examples/openfilecache.conf @@ -0,0 +1,10 @@ +server { + listen 8092; + root html; + location / { + open_file_cache max=10 inactive=60s; + open_file_cache_min_uses 1; + open_file_cache_valid 60s; + open_file_cache_errors on; + } +} diff --git a/examples/proxy.conf b/examples/proxy.conf index 52679a37d90e07daf305e269623d0bf608bf4061..11c4dc314ed1f77ac43eede96c3c546636575c57 100644 --- a/examples/proxy.conf +++ b/examples/proxy.conf @@ -1,21 +1,34 @@ -upstream proxyups { +upstream proxyupstream { server 127.0.0.1:8012 weight=1; } server { server_name proxy.taohui.tech; - error_log myerror.log info; + error_log logs/myerror.log debug; - location /a { - proxy_pass http://proxyups/www; - proxy_method POST; - proxy_pass_request_headers off; + location / { + proxy_pass http://proxyupstream; + #proxy_method POST; + + proxy_hide_header aaa; + proxy_pass_header server; + proxy_ignore_headers X-Accel-Limit-Rate; + + #proxy_pass_request_headers off; #proxy_pass_request_body off; - proxy_set_body 'hello world!'; - proxy_set_header name ''; + #proxy_set_body 'hello world!'; + #proxy_set_header name ''; proxy_http_version 1.1; proxy_set_header Connection ""; } + + listen 80; # managed by Certbot + + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/proxy.taohui.tech/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/proxy.taohui.tech/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } diff --git a/examples/slice.conf b/examples/slice.conf new file mode 100644 index 0000000000000000000000000000000000000000..f7e3358d9a332f4272759ecda5605118d71d7960 --- /dev/null +++ b/examples/slice.conf @@ -0,0 +1,24 @@ +proxy_cache_path /data/nginx/tmpcache3 levels=2:2 keys_zone=three:10m loader_threshold=300 + loader_files=200 max_size=200m inactive=1m; + +server { + server_name slice.taohui.tech; + + error_log logs/cacherr.log debug; + + location ~ /purge(/.*) { + proxy_cache_purge three $1$is_args$args$slice_range; + } + + location /{ + proxy_cache three; + slice 1m; + proxy_cache_key $uri$is_args$args$slice_range; + proxy_set_header Range $slice_range; + + proxy_cache_valid 200 206 1m; + add_header X-Cache-Status $upstream_cache_status; + + proxy_pass http://localhost:8012; + } +} diff --git a/examples/store.conf b/examples/store.conf new file mode 100644 index 0000000000000000000000000000000000000000..810dfe84768e12e1399fc939ead1acc8bf046dfa --- /dev/null +++ b/examples/store.conf @@ -0,0 +1,19 @@ +upstream proxyups { + server 127.0.0.1:8012 weight=1; +} + +server { + server_name store.taohui.tech; + error_log logs/myerror.log debug; + root /tmp; + + location / { + proxy_pass http://proxyups; + proxy_store on; + proxy_store_access user:rw group:rw all:r; + } + + listen 80; # managed by Certbot +} + + diff --git a/examples/stream.conf b/examples/stream.conf new file mode 100644 index 0000000000000000000000000000000000000000..4beac21c56cf75ee667cea3e6b433b180465f25c --- /dev/null +++ b/examples/stream.conf @@ -0,0 +1,7 @@ +stream { + server { + listen 10001; + return 'hello, $remote_addr!\n'; + } +} + diff --git a/examples/streamups.conf b/examples/streamups.conf new file mode 100644 index 0000000000000000000000000000000000000000..deccaa6c35fab064967320ad22fbd2f08cf62447 --- /dev/null +++ b/examples/streamups.conf @@ -0,0 +1,40 @@ +stream { + log_format basic '$remote_addr [$time_local] ' + '$protocol $status $bytes_sent $bytes_received ' + '$session_time'; + + error_log logs/stream_error.log debug; + access_log logs/stream_access.log basic; + server { + listen 10002 proxy_protocol; + return '10002 server get ip: $remote_addr!\n'; + } + + server { + listen 10003 proxy_protocol; + return '10003 server get ip: $remote_addr!\n'; + } + + server { + #listen 10004; + listen 10004 proxy_protocol; + set_real_ip_from 127.0.0.1; + allow 202.112.144.236; + deny all; + return '10004 vars: +bytes_received: $bytes_received +bytes_sent: $bytes_sent +proxy_protocol_addr: $proxy_protocol_addr +proxy_protocol_port: $proxy_protocol_port +remote_addr: $remote_addr +remote_port: $remote_port +realip_remote_addr: $realip_remote_addr +realip_remote_port: $realip_remote_port +server_addr: $server_addr +server_port: $server_port +session_time: $session_time +status: $status +protocol: $protocol +'; + } +} diff --git a/examples/upserver.conf b/examples/upserver.conf new file mode 100644 index 0000000000000000000000000000000000000000..33090e24bb7881e1c2e8d0299938f7bc751308da --- /dev/null +++ b/examples/upserver.conf @@ -0,0 +1,39 @@ +server { + listen 127.0.0.1:8011; + default_type text/plain; + limit_rate 1; + return 200 '8011 server response.\n'; +} + +server { + listen 8013; + default_type text/plain; + return 500 '8013 Server Internal Error.\n'; +} + +server { + listen 8012; + default_type text/plain; + #client_body_in_single_buffer on; + #add_header Cache-Control 'max-age=3,stale-while-revalidate=3'; + #add_header Vary *; + #add_header X-Accel-Expires 3; + root html; + + location / { + #add_header aaa 'aaa value'; + #add_header X-Accel-Limit-Rate 10; + } + + location /test { + return 200 '8012 server response. +uri: $uri +method: $request_method +request: $request +http_name: $http_name +curtime: $time_local +\n'; + } +} + + diff --git a/examples/websocket.conf b/examples/websocket.conf new file mode 100644 index 0000000000000000000000000000000000000000..0a8e18c8a560abadaf3945dc90f3e34acce20e57 --- /dev/null +++ b/examples/websocket.conf @@ -0,0 +1,23 @@ +server { + server_name websocket.taohui.tech; + #root html/; + default_type text/plain; + + access_log logs/ws.log; + + location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://echo.websocket.org; + } + + listen 80; # managed by Certbot + + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/websocket.taohui.tech/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/websocket.taohui.tech/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +}