Last active
May 29, 2018 06:12
-
-
Save ethnchao/4b29459a6e5a0fa5c7b292e47d91e4a9 to your computer and use it in GitHub Desktop.
Nginx Configurations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Global Configuration | |
user nginx; | |
worker_processes 8; | |
events { | |
worker_connections 4096; | |
} | |
error_log /var/log/nginx/nginx.error.log error; | |
pid /usr/local/nginx/logs/nginx.pid; | |
## HTTP | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
## Log format | |
log_format main '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" ' | |
'"$gzip_ratio" "$request_time" "$upstream_response_time" "$upstream_addr" ' | |
'"$upstream_cache_status" "$upstream_status" '; | |
log_format download '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" ' | |
'"$http_range" "$sent_http_content_range" '; | |
client_max_body_size 100m; | |
client_header_buffer_size 32k; | |
large_client_header_buffers 4 32k; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
send_timeout 10; | |
keepalive_timeout 65; | |
client_body_timeout 10; | |
client_header_timeout 10; | |
## Gzip | |
gzip on; | |
gzip_min_length 1k; | |
gzip_buffers 4 16k; | |
gzip_http_version 1.1; | |
gzip_comp_level 2; | |
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/svg+xml; | |
gzip_disable "MSIE [1-6]\."; | |
include ./sites-enabled/*.conf; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_redirect http:// $scheme://; | |
proxy_intercept_errors on; | |
proxy_set_header Host $host:$server_port; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
client_body_buffer_size 128k; | |
proxy_connect_timeout 1000; | |
proxy_send_timeout 1000; | |
proxy_read_timeout 1000; | |
proxy_buffer_size 128k; | |
proxy_buffers 4 256k; | |
proxy_busy_buffers_size 256k; | |
proxy_temp_file_write_size 256k; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream demo-upstream { | |
server 172.12.0.14:8080 max_fails=1 fail_timeout=10s; | |
} | |
server { | |
listen 8001; | |
server_name 172.12.0.15; | |
access_log /usr/local/nginx/logs/demo-access.log main; | |
location / { | |
proxy_pass http://demo-upstream; | |
include proxy.conf; | |
} | |
} | |
server { | |
listen 80; | |
server_name share.demo.io 172.12.0.15; | |
access_log /usr/local/nginx/logs/share-demo-io-access.log main; | |
charset utf-8,gbk; | |
location ^~ /software { | |
root /opt/share/; | |
autoindex on; | |
} | |
location ^~ /demo-test { | |
root /var/www/demo/; | |
} | |
location = / { | |
root html; | |
index index.html index.htm; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment