1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-28 17:51:24 +00:00
dockerfiles/nginx/README.md

97 lines
1.8 KiB
Markdown
Raw Normal View History

2015-07-01 11:57:52 +00:00
nginx
=====
2016-02-24 03:23:49 +00:00
![](https://badge.imagelayers.io/vimagick/nginx:latest.svg)
[Nginx][1] is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and
2015-07-01 11:57:52 +00:00
IMAP protocols, as well as a load balancer, HTTP cache, and a web server
(origin server).
2015-12-04 11:50:20 +00:00
## Static Website
2016-02-24 03:23:49 +00:00
File: docker-compose.yml
2015-07-01 11:57:52 +00:00
2017-04-30 15:36:09 +00:00
```yaml
2015-07-01 11:57:52 +00:00
nginx:
2017-04-30 15:36:09 +00:00
image: nginx:alpine
2015-07-01 11:57:52 +00:00
ports:
- "80:80"
volumes:
2021-02-02 10:22:31 +00:00
- ./data/conf.d:/etc/nginx/conf.d
2017-04-30 15:36:09 +00:00
- ./data/html:/usr/share/nginx/html
2021-02-02 10:22:31 +00:00
restart: unless-stopped
2015-12-04 11:50:20 +00:00
```
2017-04-30 15:36:09 +00:00
## Reverse Proxy
2015-12-04 11:50:20 +00:00
2016-02-24 03:23:49 +00:00
File: docker-compose.yml
2015-12-04 11:50:20 +00:00
2017-04-30 15:36:09 +00:00
```yaml
2015-12-04 11:50:20 +00:00
nginx:
2017-04-30 15:36:09 +00:00
image: nginx:alpine
2015-12-04 11:50:20 +00:00
volumes:
2021-02-02 10:22:31 +00:00
- ./data/conf.d:/etc/nginx/conf.d
2017-04-30 15:36:09 +00:00
- ./data/ssl:/etc/nginx/ssl
- ./data/htpasswd:/etc/nginx/htpasswd
2015-12-04 11:50:20 +00:00
net: host
2021-02-02 10:22:31 +00:00
restart: unless-stopped
2015-07-01 11:57:52 +00:00
```
2015-12-04 11:50:20 +00:00
> Password file can be generated by:
2017-04-30 15:36:09 +00:00
>> `echo "username:$(openssl passwd -apr1 password)" >> data/htpasswd`
2015-12-04 11:50:20 +00:00
2016-02-24 03:23:49 +00:00
File: default
2015-12-04 11:50:20 +00:00
2017-04-30 15:36:09 +00:00
```nginx
2015-12-04 11:50:20 +00:00
server {
listen 80 default;
server_name _;
return 301 http://blog.foobar.site/;
}
server {
listen 80;
2016-05-01 01:06:20 +00:00
server_name blog.foobar.site blog.easypi.info;
2015-12-04 11:50:20 +00:00
location / {
proxy_pass http://127.0.0.1:6109;
}
}
server {
listen 80;
2016-05-01 01:06:20 +00:00
server_name wiki.foobar.site wiki.easypi.info;
2015-12-04 11:50:20 +00:00
location / {
auth_basic restricted;
auth_basic_user_file /etc/nginx/htpasswd;
proxy_pass http://127.0.0.1:8000;
}
}
server {
listen 80;
2016-05-01 01:06:20 +00:00
server_name iot.foobar.site iot.easypi.info;
2015-12-04 11:50:20 +00:00
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";
}
}
```
2016-02-24 03:23:49 +00:00
File: [rtmp][1]
2017-04-30 15:36:09 +00:00
```nginx
2016-02-24 03:23:49 +00:00
rtmp {
server {
listen 1935;
application live {
live on;
}
}
}
```
[1]: http://nginx.org/
[2]: https://github.com/arut/nginx-rtmp-module/wiki/Directives