DOCKER 创建 配置 运行 NGINX 环境(阿里云服务器)

1. 拉取nginx

#拉取nginx的最新稳定版
sudo docker pull nginx

2.Docker创建Nginx容器并运行

#1.映射端口 80:80 ===>443:443 端口 
#2.配置数据保存路径 /opt/nginx/conf.d :/etc/nginx/conf.d
$docker run -d \
--name=nginx \
--restart always \
-p 80:80 -p 443:443 \
-v /opt/nginx/conf.d:/etc/nginx/conf.d \
nginx

3.配置NGINX的server信息

## conf
- $mkdir /opt/nginx/conf.d
  $ cd /opt/nginx/conf.d # 创建这个目录来加载nginx配置文件夹
- $vim demo.auicyh.com.conf #创建文件 加入下面的配置 文件的名称要和域名一致
## server_name 要访问的二级域名或者一级域名
## proxy_pass 监听服务器的端口 
```conf
server {
	listen 80;
	server_name demo.auicyh.com;
	client_max_body_size 100M;
	location / {
		proxy_pass http://XX.XX.XXX.XX:28080;
	}
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /usr/share/nginx/html;
	}
}

4.如果是阿里云的服务器需要在阿里云后台配置相应的端口

猜你喜欢

转载自blog.csdn.net/yinlell/article/details/83755842