Skip to content

Instantly share code, notes, and snippets.

@yunghoy
Last active November 15, 2017 03:14
Show Gist options
  • Select an option

  • Save yunghoy/d876c961a45fca174075ef801822ea69 to your computer and use it in GitHub Desktop.

Select an option

Save yunghoy/d876c961a45fca174075ef801822ea69 to your computer and use it in GitHub Desktop.
Nginx Settings
user nobody nogroup;
worker_processes auto; # auto-detect number of logical CPU cores
events {
worker_connections 1024; # set the max number of simultaneous connections (per worker process)
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log off;
error_log off;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
# ##
# # Test Load Balancing Proxy
# ##
# upstream myapp1 {
# #ip_hash; # Session persistence
# least_conn; # Least connected load balancing
# server google.com weight=2; # Weighted load balancing
# server naver.com;
# }
# server {
# listen *:8888;
#
# location / {
# proxy_pass http://myapp1;
# }
# }
# ##
# # Test Changed Behavior
# ##
# server {
# listen *:8888;
# server_name "";
# charset utf-8;
# resolver 8.8.8.8;
#
# set $upstream_endpoint http://google.com;
#
# location /foo/ {
# rewrite ^/foo/(.*) /$1 break; # /foo/bar/baz -> /bar/baz
# proxy_pass $upstream_endpoint;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $host;
#
# proxy_connect_timeout 10;
# proxy_send_timeout 20;
# proxy_read_timeout 20;
# }
# }
##
# Test HTTP Proxy
##
server {
listen *:8080; # from a port of any ethernet ip interface
server_name ""; # from any domain name hosts
charset utf-8;
resolver 8.8.8.8; # DNS resolver
location / {
proxy_pass https://google.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_connect_timeout 10;
proxy_send_timeout 20;
proxy_read_timeout 20;
}
}
}
stream {
##
# Test TCP Stream Proxy
##
server {
listen *:2222;
proxy_pass yourhost.com:22;
proxy_timeout 20s;
proxy_connect_timeout 10s;
}
}
stream {
upstream stream_backend {
server yourhost.com:22 weight=1;
}
server {
listen 2222;
proxy_pass stream_backend;
}
}
stream {
##
# Test TCP Stream Proxy
##
server {
listen 53 udp;
proxy_pass juniper_close_stream_backend;
}
upstream juniper_close_stream_backend {
server 110.169.193.4:8600;
server 110.169.193.5:8600;
}
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment