Skip to content

Instantly share code, notes, and snippets.

@Amar-Chaudhari
Last active December 4, 2020 17:27
Show Gist options
  • Select an option

  • Save Amar-Chaudhari/0de5bf8d209614c59200043356f5cfa9 to your computer and use it in GitHub Desktop.

Select an option

Save Amar-Chaudhari/0de5bf8d209614c59200043356f5cfa9 to your computer and use it in GitHub Desktop.

Revisions

  1. Amar-Chaudhari revised this gist Jul 6, 2016. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ Domain : xyz.com
    server {
    listen 80;
    server_name xyz.com;
    access_log /var/webapps/xyz.com/logs/access.log;
    error_log /var/webapps/xyz.com/logs/error.log;
    @@ -38,16 +38,17 @@ server {
    # serve static content
    location /static/ {
    # Update correct static folder path
    root /var/webapps/sbprod/xyz/main/;
    root /var/webapps/xyz/main/;
    }
    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;
    # use the sock created in above gunicorn file
    proxy_pass http://unix:/var/webapps/run/SOMENAME.sock;
    #Use the sock created in above gunicorn file
    }
    }
    ```
  2. Amar-Chaudhari created this gist Jul 6, 2016.
    53 changes: 53 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    # Nginx + Gunicorn + Django

    ## Gunicorn configuration
    Filename : /etc/systemd/system/gunicorn.service

    ```
    [Unit]
    Description=gunicorn daemon
    After=network.target
    [Service]
    # Update all paths below
    # Setting provided are for reference only !
    User=webapp
    Group=www
    WorkingDirectory=/var/webapps/sbprod/django_project_dir
    ExecStart=/var/webapps/virtual_sample_env/bin/gunicorn --workers 2 --bind unix:/var/webapps/run/SOMENAME.sock Django_project_name.wsgi:application
    [Install]
    WantedBy=multi-user.target
    ```

    ## Nginx configuration
    Domain : xyz.com
    ```
    server {
    listen 80;
    server_name xyz.com;
    access_log /var/webapps/xyz.com/logs/access.log;
    error_log /var/webapps/xyz.com/logs/error.log;
    root /var/webapps/xyz.com/public_html/;
    index index.php index.html index.htm;
    location = /favicon.ico { access_log off; log_not_found off; }
    # serve static content
    location /static/ {
    # Update correct static folder path
    root /var/webapps/sbprod/xyz/main/;
    }
    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:/var/webapps/run/SOMENAME.sock;
    #Use the sock created in above gunicorn file
    }
    }
    ```