1
rated 0 times
[
1]
[
0]
/ answers: 1 / hits: 1328
/ 2 Years ago, sun, august 21, 2022, 6:08:16
I have a SSL setup on my nginx server and the SSL works perfectly, only problem is it is working on all other virtual hosts and also the server IP which I don't want it to. It should only work in the same server block as the domain where the ssl is activated.
Here is the server blocks:
server {
listen 80;
root /var/www;
index index.html index.htm index.php;
server_name SERVER.IP.HERE;
location / {
try_files $uri $uri/ /index.html;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 443;
server_name SERVER.IP.HERE;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
}
server {
listen 80;
root /var/www/example.com;
index index.html index.htm index.php;
server_name example.com;
location / {
try_files $uri $uri/ /index.html;
}
}
I want the ssl to work on the server IP and NOT the example.com virtual host. What's the best way to do this?
Thanks.
More From » server