listen 443 ssl http2 default_server;
server_name domain.com www.domain.com;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets off;
ssl_certificate /path/to/fullchain.cer;
ssl_trusted_certificate /path/to/fullchain.cer;
ssl_certificate_key /path/to/cert.key;
ssl_dhparam /path/to/dhparam.pem;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384';
ssl_ecdh_curve secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
ssl_verify_depth 3;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 10s;
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload";
add_header X-Farme-Options "DENY";
add_header X-Content-Type-Options "nosniff";
add_header X-XSS-Protection "1; mode=block";
charset utf-8;
server_tokens off;
root /path/to/root;
acme.sh --issue -d example.com -d *.example.com --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please
acme.sh --renew -d example.com -d *.example.com --yes-I-know-dns-manual-mode-enough-go-ahead-please
server {
listen 80;
server_name sitename.ru www.sitename.ru;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name sitename.ru;
ssl_certificate /etc/nginx/ssl/sitename.ru/sitename.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename.ru/sitename.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename/sitename.ru/www;
access_log /var/log/nginx/sitename.ru.access.log;
error_log /var/log/nginx/sitename.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
return 301 https://$host$request_uri;
access_log off;
вместо записи в /dev/nullHost: sitename2.ru
, а сертификат на sitename.ru). Нужно для каждого домена завести свой server с нужным доменным именем + default_server который будет обрабатывать всё остальное. Что-то вродеserver {
listen 80;
server_name sitename.ru www.sitename.ru;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name sitename.ru www.sitename.ru;
ssl_certificate /etc/nginx/ssl/sitename.ru/sitename.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename.ru/sitename.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename/sitename.ru/www;
access_log /var/log/nginx/sitename.ru.access.log;
error_log /var/log/nginx/sitename.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 443 ssl;
server_name sitename2.ru www.sitename2.ru;
ssl_certificate /etc/nginx/ssl/sitename.ru/sitename2.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename.ru/sitename2.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename/sitename2.ru/www;
access_log /var/log/nginx/sitename2.ru.access.log;
error_log /var/log/nginx/sitename2.ru.error.log info;
error_page 404 = @fallback;
location / {
...
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
...
}
location @fallback {
...
}
}
user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
timer_resolution 100ms;
worker_rlimit_nofile 8192;
events {
worker_connections 2048;
# multi_accept on;
use epoll;
}
http {
server_names_hash_bucket_size 128;
include /etc/nginx/mime.types;
charset UTF-8;
access_log /var/log/nginx/access.log;
default_type application/octet-stream;
# log_format main '$remote_addr - $remote_user [$time_local] $statu$ '$request $body_bytes_sent $http_referer ' '$http_user_agent "http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_types text/plain application/xml application/x-javascript text/css;
output_buffers 1 32k;
postpone_output 1460;
ignore_invalid_headers on;
client_max_body_size 512m;
server_tokens off;
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
proxy_read_timeout 10m;
connection_pool_size 1k;
large_client_header_buffers 4 2k;
# upload_progress proxied 2m;
request_pool_size 4k;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:20m inactive=10m max_size=256m;
proxy_temp_path /var/cache/nginx/temp;
proxy_cache_valid any 20m;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*.conf;
}
server {
listen 80;
server_name sitename.ru www.sitename.ru;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name sitename.ru;
ssl_certificate /etc/nginx/ssl/sitename.ru/sitename.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename.ru/sitename.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename/sitename.ru/www;
access_log /var/log/nginx/sitename.ru.access.log;
error_log /var/log/nginx/sitename.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name sitename2.ru www.sitename2.ru;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name sitename2.ru;
ssl_certificate /etc/nginx/ssl/sitename2.ru/sitename2.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename2.ru/sitename2.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename2/sitename2.ru/www;
access_log /var/log/nginx/sitename2.ru.access.log;
error_log /var/log/nginx/sitename2.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
timer_resolution 100ms;
worker_rlimit_nofile 8192;
events {
worker_connections 2048;
use epoll;
}
http {
server_names_hash_bucket_size 128;
include /etc/nginx/mime.types;
charset UTF-8;
access_log /var/log/nginx/access.log;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_types text/plain application/xml application/x-javascript text/css;
output_buffers 1 32k;
postpone_output 1460;
ignore_invalid_headers on;
client_max_body_size 512m;
server_tokens off;
client_header_timeout 10m;
client_body_timeout 10m;
send_timeout 10m;
proxy_read_timeout 10m;
connection_pool_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:20m inactive=10m max_size=256m;
proxy_temp_path /var/cache/nginx/temp;
proxy_cache_valid any 20m;
server {
listen 80 default_server;
return 403;
}
server {
listen 80;
server_name sitename.ru www.sitename.ru;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 80;
server_name sitename2.ru www.sitename2.ru;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name sitename.ru www.sitename.ru;
ssl_certificate /etc/nginx/ssl/sitename.ru/sitename.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename.ru/sitename.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename/sitename.ru/www;
access_log /var/log/nginx/sitename.ru.access.log;
error_log /var/log/nginx/sitename.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 443 ssl;
server_name sitename2.ru www.sitename2.ru;
ssl_certificate /etc/nginx/ssl/sitename2.ru/sitename2.ru.crt;
ssl_certificate_key /etc/nginx/ssl/sitename2.ru/sitename2.ru.key;
include /etc/nginx/templates/ssl.conf;
root /home/users/sitename2/sitename2.ru/www;
access_log /var/log/nginx/sitename2.ru.access.log;
error_log /var/log/nginx/sitename2.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
server {
listen 80;
server_name sitenameN.ru www.sitenameN.ru;
root /home/users/sitenameN/sitenameN.ru/www;
access_log /var/log/nginx/sitenameN.ru.access.log;
error_log /var/log/nginx/sitenameN.ru.error.log info;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
access_log /dev/null;
error_log /dev/null crit;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/;
index index.html index.htm;
server_name localhost;
}