概述
docker pull nginx
mkdir -p /agui/docker-nginx/html
chmod 777 /agui/docker-nginx/html
mkdir -p /agui/docker-nginx/conf.d
mkdir -p /agui/docker-nginx/conf
mkdir -p /agui/docker-nginx/log
chmod 777 /agui/docker-nginx/conf.d
chmod 777 /agui/docker-nginx/conf
chmod 777 /agui/docker-nginx/log
vim /agui/docker-nginx/conf/nginx.conf
nginx.conf
user nginx;
worker_processes 1;
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;
}
配置文件 default.conf
vim /agui/docker-nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html 6666.jpg;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
最后
有防火墙就开房端口:
firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --reload
//启动docker 镜像。
docker run --name nginx -p 8081:80 -v /agui/docker-nginx/html:/usr/share/nginx/html -v /agui/docker-nginx/log:/var/log/nginx -v /agui/docker-nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro -v /agui/docker-nginx/conf.d:/etc/nginx/conf.d --privileged=true -d nginx
访问:http://ip:8081/
最后
以上就是专一电灯胆为你收集整理的Docker 搭建 nginx 过程。的全部内容,希望文章能够帮你解决Docker 搭建 nginx 过程。所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复