Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jch/bd1b1a8d636ccf815357ce9bebd7ec2b to your computer and use it in GitHub Desktop.

Select an option

Save jch/bd1b1a8d636ccf815357ce9bebd7ec2b to your computer and use it in GitHub Desktop.

Revisions

  1. jch revised this gist Dec 12, 2022. 2 changed files with 6 additions and 6 deletions.
    6 changes: 3 additions & 3 deletions a Super-simple Nginx reverse proxy with Homebrew on OS X.md
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@
    ### 1)
    ```sh
    brew install nginx
    sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchAgents
    sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchDaemons
    ```

    ### 2)
    Replace `/usr/local/etc/nginx/nginx.conf` with the `nginx.conf` in this gist. I'm using port 5000 for my current project. Obviously, change `server_name` as well, and probably the name of its access log.
    Replace `/usr/local/etc/nginx/nginx.conf` with the `nginx.conf` in this gist. I'm using port 8888 for my current project. Obviously, change `server_name` as well, and probably the name of its access log.

    ### 3)
    `sudo launchctl load /Library/LaunchAgents/homebrew.mxcl.nginx.plist`
    `sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist`
    6 changes: 3 additions & 3 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -29,11 +29,11 @@ http {

    server {
    listen 80;
    server_name dev.copypastafarianism.org;
    access_log /usr/local/var/log/nginx/copypastafarianism.access.log main;
    server_name foo.test;
    access_log /usr/local/var/log/nginx/foo.access.log main;

    location / {
    proxy_pass http://0.0.0.0:5000;
    proxy_pass http://0.0.0.0:8888;
    }
    }
    }
  2. @natchiketa natchiketa renamed this gist Sep 11, 2015. 1 changed file with 0 additions and 0 deletions.
  3. @natchiketa natchiketa renamed this gist Sep 11, 2015. 1 changed file with 0 additions and 0 deletions.
  4. @natchiketa natchiketa renamed this gist Sep 11, 2015. 1 changed file with 0 additions and 0 deletions.
  5. @natchiketa natchiketa revised this gist Sep 11, 2015. 1 changed file with 39 additions and 0 deletions.
    39 changes: 39 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    # Replace /usr/local/etc/nginx/nginx.conf with this. This is the
    # default location for Nginx according to 'nginx -h'
    worker_processes 1;
    error_log /usr/local/var/log/nginx/error.log;

    events {
    worker_connections 1024;
    }

    http {
    # This should be in the same directory as this conf
    # e.g. /usr/local/etc/nginx
    include mime.types;
    default_type application/octet-stream;

    # Note this log_format is named 'main', and is used with the access log below
    log_format main '$remote_addr - $remote_user [$time_local] $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile on;
    keepalive_timeout 65;

    # Without this I got this error: 'upstream sent too big header
    # while reading response header from upstream'
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;

    server {
    listen 80;
    server_name dev.copypastafarianism.org;
    access_log /usr/local/var/log/nginx/copypastafarianism.access.log main;

    location / {
    proxy_pass http://0.0.0.0:5000;
    }
    }
    }
  6. @natchiketa natchiketa created this gist Sep 11, 2015.
    13 changes: 13 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    # Installation

    ### 1)
    ```sh
    brew install nginx
    sudo cp /usr/local/Cellar/nginx/1.8.0/homebrew.mxcl.nginx.plist /Library/LaunchAgents
    ```

    ### 2)
    Replace `/usr/local/etc/nginx/nginx.conf` with the `nginx.conf` in this gist. I'm using port 5000 for my current project. Obviously, change `server_name` as well, and probably the name of its access log.

    ### 3)
    `sudo launchctl load /Library/LaunchAgents/homebrew.mxcl.nginx.plist`