HUB
Sign inSign up

dockerwkm/nginx

By dockerwkm

•Updated about 5 years ago

Image
0

45

dockerwkm/nginx repository overview

⁠前言

使用nginx共享-代理本地网络

⁠运行容器
# 创建好other 相关文件后启动容器
[root@localhost ~]#  docker run --name=nginx --net=host  \
-v /docker/nginx/nginx.conf:/etc/nginx/nginx.conf  \
-v /docker/nginx/conf.d:/etc/nginx/conf.d \
-v /docker/nginx/html:/etc/nginx/html  \
-d nginx:stable-alpine-perl

⁠other 相关
#目录结构
[root@localhost ~]# tree /docker/nginx/
/docker/nginx/
├── conf.d
│   └── default.conf
├── html
│   └── index.html
└── nginx.conf

2 directories, 3 files
#配置文件示例
[root@localhost html]# cat /docker/nginx/nginx.conf

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
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;
    #/etc/nginx/html
}
[root@localhost ~]# cat /docker/nginx/conf.d/default.conf
server {
    listen       80;
    listen  [::]:80;
    server_name  127.0.0.1;

    location / {
        #root   /usr/share/nginx/html;
        root   /etc/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
#静态页面示例
[root@localhost html]# cat /docker/nginx/html/index.html
<h1>hello word</h1>
#测试请求
[root@localhost html]# curl http://localhost
<h1>hello word</h1>


Tag summary
Recent tags
Content type
Image
Digest
Size
17.9 MB
Last updated
about 5 years ago
docker pull dockerwkm/nginx:stable-alpine-perl