1.拉取镜像
docker pull docker.io/nginx
2.docker
部署
docker run -itd \
--name nginx \
--restart always \
-p "80:80" \
-v "/usr/share/nginx:/usr/share/nginx" \
-v "/usr/share/nginx/html:/usr/share/nginx/html" \
-v "/usr/nginx/lib/nginx:/usr/lib/nginx" \
-v "/usr/nginx/default.conf:/etc/nginx/conf.d/default.conf" \
-m "512M" \
docker.io/nginx
3.docker-compose
部署
version: '2.0'
services:
nginx:
image: docker.io/nginx
container_name: nginx
restart: always
ports:
- 80:80
volumes:
- ./nginx/usr/share/nginx:/usr/share/nginx
- ./nginx/usr/share/nginx/html:/usr/share/nginx/html
- ./nginx/lib/nginx:/usr/lib/nginx
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
deploy:
resources:
limits:
cpus: '0.2'
memory: 512M
reservations:
cpus: '0.2'
memory: 512M
docker-compose -f nginx.yaml up [-d]
附件:
nginx.conf
配置文件
server {
listen 80;
listen [::]:80;
server_name localhost;
# 项目1
location /p1 {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /p1/index.html;
}
# 项目2
location /p2 {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /p2/index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
附注:关于nginx转发云上接口
location / {
proxy_pass https://suggest.taobao.com/sug?code=utf-8&q=内裤&callback=cb;
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。