docker-compose up -d nginx
配置nginx多域名的话,有两种方式,一种是在一个工作空间里面放置多个项目,另一种就是启动多个工作空间,我们这里主要正对的一个工作区里面的多个项目
在nginx的容器里的/etc/nginx/目录下,创建一个vhost目录,而在nginx.conf文件下,注释掉这行,
include /etc/nginx/sites-available/*.conf;
添加一行。
include /etc/nginx/vhost/*.conf;
然后再nginx目录下新建vhost文件夹,再将/etc/nginx/sites-available/目录下的default.conf复制一份到vhost文件夹下,就以网址命名吧,ccab.conf,多个域名就将server_name后面换掉,如果对应的项目地址不一样的话,就将root后面的换掉。
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
# For https
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;
server_name ccab.com www.ccab.com;
root /var/www/项目地址/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
}
原文:https://www.cnblogs.com/7heOne/p/14840749.html