NGINX Commands (Ubuntu)

A short guide of commands I've found myself using on Ubuntu for NGINX, I'll update this post as I find more.

Installing NGINX

sudo apt-get update

sudo apt-get install nginx

Restarting NGINX

To restart NGINX

sudo systemctl restart nginx

To just reload the NGINX

nginx -s reload

This will reload the NGINX config and any changes you make to it.

NGINX Config

A Sample Config for one of my static sites.

server {
  listen 80;

  listen [::]:80;

  root /var/www/jameskenny.co;

  index index.html;

  server_name jameskenny.io www.jameskenny.io;

  location / {
    try_files $uri $uri/ =404;
  }
}

A sample config of a reverse proxy for a docker container.

server {
  listen 80;

  listen [::]:80;

  server_name touroperator.io www.touroperator.io;

   set $upstream 127.0.0.1:8080;

 location / {
 
 proxy_pass_header Authorization;
 proxy_pass http://$upstream;
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_http_version 1.1;
 proxy_set_header Connection "";
 proxy_buffering off;
 client_max_body_size 0;
 proxy_read_timeout 36000s;
 proxy_redirect off;

 }
}

CloudStatus

We have been using cloud services to build products and web sites getting alerts has helped us stay ahead of issues that might happen. We track over 300 sources of information for Microsoft Windows Azure, Google Cloud, Amazon Web Services, MailGun, Github, bitbucket and more.

Try Cloudstatus
comments powered by Disqus