Skip to content

ameyrupji-local/ameyrupji.local-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ameyrupj.local-nginx-setup

This repository outlines the steps to setup nginx on MacOS to act as a reverse proxy for various apps deployed on my local server.

Prerequisites

System Configuration at time of test

  • macOS High Sierra - Version 10.13.6
  • Sharing > Local Hostname set to ameyrupji.local macOS sharing

Installation instructions

Brew install

These instructions are used to install nginx using brew

Use brew to install the nginx run the following command in a terminal: brew install nginx

To start nginx server run in terminal: sudo nginx

To check that the services is started use this command brew services list

terminal brew install nginx

Nginx is installed on port 8080 by default. Open Safari and going to URL: http:https://localhost:8080

Nginx is now installed!

safari nginx port 8080

Changing the default port to 80

The default place of nginx.conf on Mac after installing with brew is: /usr/local/etc/nginx/nginx.conf

Changing the default port to 80. First stop the nginx server if it is running by using the following commands: sudo nginx -s stop

terminal nginx stop

Then open nginx.conf with vim in terminal: vim /usr/local/etc/nginx/nginx.conf

and change the:

http {
    ...

    server {
        listen       8080;
        server_name  localhost;

        ...

to:

http {
    ...

    server {
        listen       80;
        server_name  localhost;

        ...

Save configuration and relaunch nginx sudo nginx

Enable nginx auto start on reboot

Before the testing can begin lets setup Nginx to autostart on reboot. Use the following commands to enable this: sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons and sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

terminal enable boot start

Test

Open Safari it by going to URL: http:https://localhost

safari nginx port 80

This website should also be accessible over the network from another computer at http:https://ameyrupji.local/

network safari nginx

Cleanup

To uninstall nginx:

First stop the nginx server if it is running by: sudo nginx -s stop

Using brew to uninstall Nginx run the command: brew uninstall nginx

Remove Nginx code by running the following commands: rm -f -R /usr/local/nginx and rm -f /usr/local/sbin/nginx

Useful Links

Releases

No releases published

Packages

No packages published