我有一个带有 nginx 版本的 ubuntu hardy:nginx/0.5.33
我有多个服务器,它们在端口 80 上运行良好。
现在,其中一些我想在端口 443 上使用 SSL 提供服务,并且每个人都有自己的 ssl 证书。
问题是每个域都使用相同的 ssl 证书,并且浏览器中出现错误,指出名称不匹配的 ssl 证书。
我确信所有的证书都是有效的并且是正确的,路径是正确的。如果我只服务一个域,ssl 证书是可以的,所以所有的文件都可以。
为什么 nginx 总是对所有服务器配置使用相同的 ssl 证书?
这是两个示例,如果两者都处于活动状态,则域 1 始终需要 ssl,如果我删除域 1,域 2 和 ssl 可以使用正确的 ssl 文件正常工作。
谢谢,
米。
nginx.conf 文件:
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;
}
Run Code Online (Sandbox Code Playgroud)
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;
}
}
Run Code Online (Sandbox Code Playgroud)
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
您需要为要使用的每个 SSL 证书分配一个单独的 IP 地址。
http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#vhosts
http://www.ruby-forum.com/topic/186664#815383
| 归档时间: |
|
| 查看次数: |
5310 次 |
| 最近记录: |