Welcome! Log In Create A New Profile

Advanced

How to allow NGINX one domain SSLDomain1\.info to use SSL whilst rest of the domains (hundreds of them and dynamically added, need wildcard _) are simple HTTP 80 ?

Posted by nginxssl 
If I use
Server{ FOR SSLDOMAIN.info }
Server{ FOR REST}

Then
I can’t have both ssl and http ☹
It is one way or another, very annoying nginx, not flexible

Nginx gives error no matter how I try

Why can’t I use simple condition?

If ($host=”SSLDOMAIN1.info”){
ssl on;
ssl_certificate /var/www/SSLDomain1.info/ssl/SSLDomain1_info.bundle.crt;
ssl_certificate_key /var/www/SSLDomain1.info/ssl/SSLDomain1_info.key;
}



example of conf


server {
listen 80;
listen 443 ssl;



if ($host ~* (SSLDomain1\.info)){
#ssl on;
#ssl_certificate /var/www/SSLDomain1.info/ssl/SSLDomain1_info.bundle.crt;
#ssl_certificate_key /var/www/SSLDomain1.info/ssl/SSLDomain1_info.key;
}
server_name _;
server_name_in_redirect off;

if ($host ~* ^(.*\..*)$) {
set $domain $host;
}

if ($host ~* ^(.*)\.(.*\..*)$) {
set $domain $2;
}



root /var/www/$domain;

location / {
index index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?$1 last;
break;
}

location ~ \.php$ {
fastcgi_pass php;
fastcgi_index index.php;
include fastcgi.conf;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 136
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready