1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-10 11:10:29 +02:00
dockerfiles/nginx
2017-05-08 07:05:07 +08:00
..
arm update mosquitto 2017-05-06 12:59:40 +08:00
data update ghost 2017-04-30 23:36:09 +08:00
docker-compose.yml update ghost 2017-04-30 23:36:09 +08:00
Dockerfile swith to new domain: easypi.pro 2017-05-08 07:05:07 +08:00
README.md update ghost 2017-04-30 23:36:09 +08:00

nginx

Nginx is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server).

Static Website

File: docker-compose.yml

nginx:
  image: nginx:alpine
  ports:
    - "80:80"
  volumes:
    - ./data/default.conf:/etc/nginx/default.conf
    - ./data/html:/usr/share/nginx/html
  restart: always

Reverse Proxy

File: docker-compose.yml

nginx:
  image: nginx:alpine
  volumes:
    - ./data/default.conf:/etc/nginx/conf.d/default.conf
    - ./data/ssl:/etc/nginx/ssl
    - ./data/htpasswd:/etc/nginx/htpasswd
  net: host
  restart: always

Password file can be generated by:

echo "username:$(openssl passwd -apr1 password)" >> data/htpasswd

File: nginx.conf

user  nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

File: default

server {
    listen 80 default;
    server_name _;
    return 301 http://blog.foobar.site/;
}

server {
    listen 80;
    server_name blog.foobar.site blog.easypi.info;
    location / {
        proxy_pass http://127.0.0.1:6109;
    }
}

server {
    listen 80;
    server_name wiki.foobar.site wiki.easypi.info;
    location / {
        auth_basic restricted;
        auth_basic_user_file /etc/nginx/htpasswd;
        proxy_pass http://127.0.0.1:8000;
    }
}

server {
    listen 80;
    server_name iot.foobar.site iot.easypi.info;
    location / {
        proxy_pass http://127.0.0.1:1880;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

File: rtmp

rtmp {
    server {
        listen 1935;
        application live {
            live on;
        }
    }
}