Skip to content

Instantly share code, notes, and snippets.

@1isten
Last active February 1, 2021 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1isten/e4cdd9383f7601b568e10adcd720d682 to your computer and use it in GitHub Desktop.
Save 1isten/e4cdd9383f7601b568e10adcd720d682 to your computer and use it in GitHub Desktop.
Homebrew nginx (Valet version) with custom config:

In /usr/local/etc/nginx/nginx.conf (default config), Valet has included these lines:

# ...

    include "/Users/sten/.config/valet/Nginx/*";
    include servers/*; # 👈
    include valet/valet.conf;

# ...

so:

mkdir -p /usr/local/share/nginx
cd /usr/local/share/nginx
ln -sfv /usr/local/var/www html

mkdir -p /usr/local/etc/nginx/servers
cd /usr/local/etc/nginx/servers
touch static 3030to3000
@1isten
Copy link
Author

1isten commented Jan 28, 2021

/usr/local/etc/nginx/servers/static:

server {
  listen 8080;
  server_name localhost;

  root /usr/local/share/nginx/html;

  add_header X-Frame-Options "SAMEORIGIN";
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Content-Type-Options "nosniff";

  index index.html;

  charset utf-8;

  location / {
    try_files $uri $uri/ /index.html?$query_string;
  }

  location = /favicon.ico { access_log off; log_not_found off; }
  location = /robots.txt  { access_log off; log_not_found off; }

  error_page 404 /index.html;

  location ~ /\.(?!well-known).* {
    deny all;
  }
}

ref: https://laravel.com/docs/deployment#nginx

@1isten
Copy link
Author

1isten commented Jan 28, 2021

/usr/local/etc/nginx/servers/3030to3000:

server {
  listen 3030;
  server_name localhost;

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_pass http://127.0.0.1:3000;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment