Closed tkgalk closed 7 years ago
nginx_sites:
http.xxx.tld:
- |
listen 80;
server_name x1.xxxx.tld x2.xxxx.tld;
return 301 https://$host$request_uri;
x1.xxxx.tld:
- |
listen 443 default ssl;
server_name x1.xxxx.tld;
ssl on;
root /var/www/x1.xxxx.tld/www;
location / { try_files $uri $uri/ /index.html /index.php; index index.php;}
ssl_certificate_key /etc/ssl/private/x1.key;
ssl_certificate /etc/ssl/certs/x1.crt;
x2.xxxx.tld:
- |
listen 443 ssl;
server_name x2.xxxx.tld;
ssl on;
root /var/www/x2.xxx.tld/www;
location / { try_files $uri $uri/ /index.html /index.php; index index.php;}
ssl_certificate_key /etc/ssl/private/x2.key;
ssl_certificate /etc/ssl/certs/x2.crt;
:+1:
And you can event use a custom template if you have lot of that case https://github.com/jdauphant/ansible-role-nginx#9-site-configuration-using-a-custom-template
Yeah, the first answer is exactly what's needed. It creates separate files in sites-enabled
though, but that's fine.
I need to setup http -> https redirect by using multiple server blocks, how would it look like when using
nginx_sites
(multiple sites, 2x static websites + 3x Node.js APIs)?I'm aiming at something like this:
But it seems
nginx_sites
allows only for oneserver
block. Any ideas?