Answer the question
In order to leave comments, you need to log in
How to set up a separate SSL certificate in nginx for each server domain?
I created a phpMyAdmin server and a universal rule according to which all "pma" subdomains of all domains go to the server with phpMyAdmin. Each domain/server has an SSL certificate issued for the domain itself and all its subdomains.
Now SSL on pma is from the 1st domain and is configured as usual, how to configure the pma server so that it issues a certificate depending on the domain from which it is accessed?
$server_name doesn't work in an SSL directive.
pma.domen0.ru = SSL domen0.ru
pma.domen1.ru = SSL domen1.ru
pma.domen2.ru = SSL domen2.ru
pma.domen*.ru = SSL domen*.ru
server {
listen 443 ssl http2;
listen [::]:443 ssl http2 ipv6only=on;
server_name "~^pma\.(.*)$";
access_log /web/pma/acces.log;
error_log /web/pma/error.log error;
#SSL
include /etc/nginx/snippets/ssl.conf;
ssl_certificate /etc/letsencrypt/live/domen1.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domen1.ru/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/domen1.ru/fullchain.pem;
location ^~ /.well-known/acme-challenge {
default_type "text/plain";
alias /var/www/letsencrypt/.well-known/acme-challenge;
}
#увеличение размера файла и ожидания
client_max_body_size 512m;
proxy_connect_timeout 1200;
proxy_send_timeout 1200;
proxy_read_timeout 1200;
#точка входа в phpMyadmin
location / {
alias /usr/share/phpmyadmin/;
location ~ \.php$ {
try_files $uri = 404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 3600;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
access_log off;
log_not_found off;
expires 1M;
}
index index.php index.html index.htm;
}
#ошибки
error_page 404 /404.html;
location = /404.html {
internal;
root /web/errors/;
}
error_page 400 500 502 503 504 /50x.html;
location /50x.html {
internal;
root /web/errors/;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question