Skip to content

Instantly share code, notes, and snippets.

@perigee
Last active August 29, 2015 14:19
Show Gist options
  • Save perigee/48e2074066bb2dc6a859 to your computer and use it in GitHub Desktop.
Save perigee/48e2074066bb2dc6a859 to your computer and use it in GitHub Desktop.

Server Settings

MQTT

  1. mqtt cluster building

Nginx

Installation (with script for ubuntu upstart, systemd for other linux)

description "nginx http daemon"

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

env DAEMON=/usr/local/nginx/sbin/nginx
env PIDFILE=/var/run/nginx.pid

# Needed to allow Nginx to start, however, the wrong PID will be tracked
expect fork

# Test the nginx configuration (Upstart will not proceed if this fails)
pre-start exec $DAEMON -t

# Ensure nginx is shutdown gracefully
# Upstart will be tracking the wrong PID so the following is needed to stop nginx
post-stop exec start-stop-daemon --stop --pidfile $PIDFILE --name nginx --exec $DAEMON --signal QUIT

# Start Nginx
exec $DAEMON

streamer server with rtmp


rtmp {
    server {
        listen 1935;

        application live {
            live on;
	    allow publish 127.0.0.1;
        }

	application dash {
	    live on;
	    allow publish 127.0.0.1;
	    dash on;
	    dash_path /tmp/dash;
	}
    }
}


upstream app_server {
        server unix:/tmp/gunicorn.sock fail_timeout=0;
        # For a TCP configuration:
        # server 192.168.0.7:8000 fail_timeout=0;
    }



server {
        location /live {
	    proxy_buffering off;
	    add_header Cache-Control no-cache;
	}

        #location /stream {
	 #   proxy_buffering off;
	  #  add_header Cache-Control no-cache;
	#}

        location / {
            try_files $uri @proxy_to_app;
            #root   html;
            #index  index.html index.htm;
        }

        location @proxy_to_app {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_buffering off;
            proxy_pass http://app_server;
        }

        

}

Dynamic reverse proxy

  1. reverse proxy with docker
  2. reverse proxy docker with incron
  3. dynamic reverse proxy with Dnsmasq
  4. Ansible comprehensive blog
  5. Nginx load balancing and reverse proxy blog
  6. HAproxy + Nginx + Webservice text
  7. Nginx tuning for python

Asterisk

description "Asterisk"
author "Jun HU"

start on runlevel [2345]
stop  on runlevel [!2345]

# need sleep and waiting for other services .... important
pre-start exec sleep 10

#console output
respawn
exec /usr/sbin/asterisk -G sudo -g -f

Nginx

     > gunicorn -w 1 -b unix:/tmp/gunicorn.sock service:app

Consul

Consul, has multiple components, but as a whole, it is a tool for discovering and configuring services in your infrastructure.

Docker

Dockerize

  1. another way to dockerize the application
  2. nginx reverse proxy automation

Ansible

  1. deploy applications with Ansible
  2. deploy docker containers with Ansible
  3. ansible pull inside docker container
  4. strategies focus on large scale deployment
  5. thoughts on Ansible
  6. Pull ansible inside docker container

References

Blogs

  1. A comprehensive DevOps blog
  2. DevOps blog
  3. Nice blog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment