Skip to content

Instantly share code, notes, and snippets.

@vpack
Last active August 29, 2015 14:23
Show Gist options
  • Save vpack/29e76d4d91950e815148 to your computer and use it in GitHub Desktop.
Save vpack/29e76d4d91950e815148 to your computer and use it in GitHub Desktop.
Nginx

Installation

yum install -y nginx
systemctl start nginx
systemctl enable nginx

###Sample Nginx Config:

# cat /etc/nginx/conf.d/blogsite.com.conf 
server {
    listen  80;
    server_name blogsite.com;
    return 301 $scheme://www.blogsite.com$request_uri;
}
server {
    listen  80;
    server_name www.blogsite.com;
    access_log /var/log/nginx/blogsite_access.log;

    location / {
        root  /var/www/blogsite.com/html;
        index  index.html index.htm;
        try_files $uri $uri/ =404;
    }

    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root  /usr/share/nginx/html;
    }
}

server {
listen 80;
server_name example3.com;
return 301 $scheme://www.example3.com$request_uri;
}
server {
listen 80;
server_name www.example3.com;
access_log /var/log/nginx/example3_access.log;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/svpack/projects/gunicorn/mysock.sock;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment