mirror of https://github.com/stilleshan/nginx.git
Update to support docker compose
This commit is contained in:
parent
01fdcaedc1
commit
4df5cbe630
10
README.md
10
README.md
|
@ -2,6 +2,7 @@
|
|||
docker 快速部署 nginx 环境,适用于 HTML 页面站点,简单 Web 测试环境以及反向代理 docker 容器等需求.
|
||||
|
||||
## 部署
|
||||
### docker
|
||||
在 root 目录下 git clone 本仓库用来挂载相关配置文件
|
||||
```shell
|
||||
cd ~
|
||||
|
@ -18,6 +19,14 @@ docker run -d --name=nginx --restart=always \
|
|||
nginx
|
||||
```
|
||||
|
||||
### docker compose
|
||||
```shell
|
||||
cd ~
|
||||
git clone https://github.com/stilleshan/nginx.git
|
||||
cd nginx
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## 说明
|
||||
`~/nginx/conf` 用于存放`nginx 主配置`文件
|
||||
> conf 目录下为官方 nginx.conf 配置文件,已新增 include vhost 目录以方便挂载多站点配置文件.
|
||||
|
@ -33,3 +42,4 @@ docker run -d --name=nginx --restart=always \
|
|||
|
||||
## 链接
|
||||
[Docker 打造支持快速部署和迁移的 Nginx 环境](https://www.ioiox.com/archives/91.html)
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
version: "3"
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
container_name: nginx
|
||||
volumes:
|
||||
- ./conf/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./vhost:/etc/nginx/conf.d/vhost
|
||||
- ./ssl:/etc/nginx/ssl
|
||||
- ./html:/usr/share/nginx/html
|
||||
network_mode: host
|
||||
restart: always
|
|
@ -1,5 +1,5 @@
|
|||
upstream dockername {
|
||||
server 127.0.0.1:8080; # 端口改为docker容器提供的端口
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
|
@ -16,6 +16,12 @@ server {
|
|||
ssl_certificate /etc/nginx/ssl/none.cer;
|
||||
ssl_certificate_key /etc/nginx/ssl/none.key;
|
||||
|
||||
# ssl_stapling on;
|
||||
# ssl_stapling_verify on;
|
||||
# ssl_trusted_certificate /etc/nginx/ssl/none.cer;
|
||||
# resolver 8.8.8.8 8.8.4.4 valid=60s ipv6=off;
|
||||
# resolver_timeout 5s;
|
||||
|
||||
# access_log /var/log/nginx/dockername_access.log combined;
|
||||
# error_log /var/log/nginx/dockername_error.log;
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
server
|
||||
{
|
||||
listen 80;
|
||||
#listen [::]:80;
|
||||
# listen [::]:80;
|
||||
server_name www.yourdomain.com ;
|
||||
index index.html index.htm index.php default.html default.htm default.php;
|
||||
root /usr/share/nginx/html/www.yourdomain.com;
|
||||
|
||||
# return 301 https://www.yourdomain.com$request_uri;
|
||||
|
||||
#error_page 404 /404.html;
|
||||
# error_page 404 /404.html;
|
||||
|
||||
# Deny access to PHP files in specific directory
|
||||
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
|
||||
# location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
|
||||
|
||||
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
|
||||
{
|
||||
|
@ -38,14 +38,14 @@ server
|
|||
server
|
||||
{
|
||||
listen 443 ssl http2;
|
||||
#listen [::]:443 ssl http2;
|
||||
# listen [::]:443 ssl http2;
|
||||
server_name www.yourdomain.com ;
|
||||
index index.html index.htm index.php default.html default.htm default.php;
|
||||
root /usr/share/nginx/html/www.yourdomain.com;
|
||||
|
||||
# if ($host = 'yourdomain.com') {
|
||||
# return 301 https://www.yourdomain.com$request_uri;
|
||||
# }
|
||||
# if ($host = 'yourdomain.com') {
|
||||
# return 301 https://www.yourdomain.com$request_uri;
|
||||
# }
|
||||
|
||||
ssl_certificate /etc/nginx/ssl/none.cer;
|
||||
ssl_certificate_key /etc/nginx/ssl/none.key;
|
||||
|
@ -57,6 +57,12 @@ server
|
|||
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
|
||||
# ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
|
||||
|
||||
# ssl_stapling on;
|
||||
# ssl_stapling_verify on;
|
||||
# ssl_trusted_certificate /etc/nginx/ssl/none.cer;
|
||||
# resolver 8.8.8.8 8.8.4.4 valid=60s ipv6=off;
|
||||
# resolver_timeout 5s;
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# Deny access to PHP files in specific directory
|
||||
|
|
Loading…
Reference in New Issue