我有一个ubuntu hardy与Nginx版本:Nginx / 0.5.33
我有多个服务器,它们在端口80上运行良好.
现在,其中一些我想在端口443上使用SSL服务,并且每个都有自己的ssl证书.
问题是每个域都使用相同的ssl证书,并且浏览器中显示错误名称ssl证书的错误.
我确信所有证书都是有效且正确的,路径是正确的.如果我只提供一个域,则ssl证书可以,所以所有文件都可以.
为什么Nginx对所有服务器配置始终使用相同的ssl证书?
这里有两个例子,如果两个都是活动的,它总是需要domain1的ssl,如果我删除domain1,domain2和ssl可以使用正确的ssl文件.
谢谢,
米
user www-data;
worker_processes 1;
error_log /var/log/Nginx/error.log;
pid /var/run/Nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/Nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/Nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
include /etc/Nginx/conf.d/*.conf;
}
domain1.conf文件:
server {
listen 443;
server_name domain1.montx.com;
root /etc/Nginx/sites-available/domain1;
access_log /etc/Nginx/sites-available/domain1/log/Nginx.log;
error_page 500 502 503 504 /500.html;
client_max_body_size 50M;
ssl on;
ssl_certificate /etc/Nginx/conf.d/domain1.crt;
ssl_certificate_key /etc/Nginx/conf.d/domain1.key;
location / {
auth_basic "Restricted";
auth_basic_user_file domain1_htpasswd;
}
}
domain2.conf文件:
upstream thin_domain2 {
server unix:/tmp/thin_domain2.0.sock;
server unix:/tmp/thin_domain2.1.sock;
server unix:/tmp/thin_domain2.2.sock;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/Nginx/conf.d/domain2.crt;
ssl_certificate_key /etc/Nginx/conf.d/domain2.key;
server_name domain2.montx.com;
root /u/apps/domain2/current/public;
access_log /u/apps/domain2/shared/log/Nginx.log;
error_page 500 502 503 504 /500.html;
client_max_body_size 50M;
# First rewrite rule for handling maintenance page
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$/system/maintenance.html last;
break;
}
location / {
index index.html index.htm;
# Forward information about the client and host
# Otherwise our Rails app wouldn't have access to it
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_max_temp_file_size 0;
# Directly serve static content
location ~ ^/(images|javascripts|stylesheets)/ {
expires 10y;
}
if (-f $request_filename) {
break;
}
# Directly serve cached pages
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
# Otherwise let Thin handle the request
if (!-f $request_filename) {
proxy_pass http://thin_domain2;
break;
}
}
}
最佳答案
您需要为要使用的每个SSL证书分配单独的IP地址.
原文链接:https://www.f2er.com/nginx/435669.html