Skip to content

Instantly share code, notes, and snippets.

@wenweih
Last active December 9, 2015 17:01
Show Gist options
  • Save wenweih/3ae931038f4433811650 to your computer and use it in GitHub Desktop.
Save wenweih/3ae931038f4433811650 to your computer and use it in GitHub Desktop.
This is Nginx configuration with two upstream
#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 application/octet-stream;
client_max_body_size 2M;
#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;
upstream hwwsite{
server unix:/Users/hww/work/freelance/my_page/tmp/sockets/hww.socket;
}
upstream git.com{
server unix:/Users/hww/work/git/gitlab/tmp/sockets/gitlab.socket;
}
server {
listen 80;
server_name hww.com;
root /Users/hww/work/freelance/my_page/public;
try_files $uri/index.html $uri.html $uri @hwwsite;
#charset koi8-r;
access_log logs/host.access.log;
location / {
try_files $uri $uri/index.html $uri.html @hwwsite;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location @hwwsite {
# proxy_set_header Host $http_host;
proxy_set_header Host $proxy_host;
proxy_set_header X-Forwarded_Proto $scheme;
proxy_redirect off;
proxy_pass http://hwwsite;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 80;
server_name git.com;
root /Users/hww/work/git/gitlab/public;
try_files $uri/index.html $uri.html $uri @git.com;
location / {
try_files $uri $uri/index.html $uri.html @git.com;
}
location @git.com{
# proxy_set_header Host $http_host;
proxy_set_header Host $proxy_host;
proxy_redirect off;
proxy_set_header X-Forwarded_Proto $scheme;
proxy_pass http://git.com;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment