我需要为 2 个网站设置 ssl:admin 和 client,具有相同的域 abc.example.com 但不同的端口。
server {
listen 8080;
server_name abc.example.com;
root /var/www/admin/public;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
server {
listen 8443 ssl;
server_name abc.example.com;
root /var/www/admin/public;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
ssl_certificate /etc/pki/tls/certs/_example.com.crt;
ssl_certificate_key /etc/pki/tls/certs/_example.com.key;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
server {
listen 80;
server_name abc.example.com;
root /var/www/client/public;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
server {
listen 443 ssl;
server_name abc.example.com;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
ssl_certificate /etc/pki/tls/certs/_example.com.crt;
ssl_certificate_key /etc/pki/tls/certs/_example.com.key;
root /var/www/client/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
我有上面的配置,80,443,8080端口连接成功,但8443端口不工作。虽然在服务器上我已经打开了8443端口。
具体来说,当我访问链接https://abc.example.com:8443/时,浏览器显示无法访问此站点
如果有人遇到这个问题并知道如何解决它。希望你能帮助我解决它。非常感谢!