server {
listen 443 ssl;
server_name domain1;
ssl on;
ssl_certificate /etc/nginx/ssl/domain1.crt;
ssl_certificate_key /etc/nginx/ssl/domain1.key;
}
server {
listen 443 ssl;
server_name domain2;
ssl on;
ssl_certificate /etc/nginx/ssl/domain2.crt;
ssl_certificate_key /etc/nginx/ssl/domain2.key;
}
server {
listen 80;
server_name_in_redirect off;
server_name ~^(?:www\.)?(?P<host_wo_www>.+)$;
return 301 https://$host_wo_www$request_uri;
}
server {
server_name ~^(?:www\.)?(?P<host_wo_www>.+)$;
server_name_in_redirect off;
resolver 127.0.0.1;
root /var/www/$host_wo_www;
access_log /var/log/nginx/$host_wo_www-access.log;
error_log /var/log/nginx/Allhost-error.log;
............
<VirtualHost *:8000>
UseCanonicalName Off
VirtualDocumentRoot "/var/www/%0"
ServerName "%0"
ServerAlias "*.%0"
ErrorLog ${APACHE_LOG_DIR}/AllHost-error.log
LogLevel error
#CustomLog ${APACHE_LOG_DIR}/%0-access.log combined
CustomLog /dev/null combined
<Directory "/var/www/%0/">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
..............
location ~ ^/(an|announce) {
proxy_pass http://127.0.0.4:2710;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
map $host $host_wo_www {
default $host;
~^www\.(?P<wo_www>.+)$ $wo_www;
}
server {
server_name ~^(?:www\.)?(?P<host_wo_www>.+)$;
server_name_in_redirect off;
resolver 127.0.0.1;
root /var/www/$host_wo_www;
#Передавать на php-fpm примерно так, тут пример передачи для апача, для передачи на php-fpm суть та-же в принципе.
location / {
proxy_redirect off;
proxy_set_header Host $host_wo_www;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffers 8 2m;
proxy_buffer_size 10m;
proxy_busy_buffers_size 10m;
proxy_pass http://backend; # В качестве бэкенда вешайте что нравится.
}