0
我在運行單個應用程序的ubuntu上有一個nginx服務器。我想讓多個域指向此服務器。在nginx服務器上設置多個域
目前我的/ etc/nginx的/網站可用/默認看起來是這樣的:
(website1.com是一樣,我不想讓我的真實域名爲例)
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/website/public;
index index.php index.html index.htm;
server_name website1.com;
location/{
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
這有效果當有人去website1.com
現在,如果來自website2.com的人,我只是再次完全複製代碼,並更改server_name?
或者還有什麼我必須做的?
謝謝兄弟!當涉及SSL證書時,我會怎麼做? – virepo
如果您使用子域名,您可以使用通配符證書,但是如果您的網站類似於website1.com和website2.com而不是web2.website.com和web1.website.com,則您需要爲每個網站設置一個服務器塊幾乎相同的東西,只是改變server_name和ssl部分。 –
如果符合您的期望,請接受答案:D –