素材巴巴 > 程序开发 >

docker安装nginx并配置nginx.conf

程序开发 2023-09-11 16:10:25

拉取nginx镜像 

docker pull nignx

查看虚拟机内镜像

47bc1f8629ef629859d2d45537a89744b76.jpg

启动nginx看看是否成功

docker run -d --name "nginx" -p 80:80 nginx

启动后打开浏览器访问一下,确认是否可用

接下来我想修改 nginx.conf 配置文件,我们需要把我们自己定义的 nginx.conf挂载在 docker 中的nginx

首先创建挂载目录

mkdir -p /usr/dokcer_nginx_data/{conf,conf.d,html,log}

自定义 nginx.conf 文件

 server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {proxy_pass http://39.98.173.195:8080/;index  dashboard index;proxy_set_header Host       $http_host;proxy_set_header X-Real-IP $remote_addr

标签:

素材巴巴 Copyright © 2013-2021 http://www.sucaibaba.com/. Some Rights Reserved. 备案号:备案中。