我有一个带有一些API的rails 4项目。
该项目在生产上与nginx v.1.6.3和https一起运行。
Nginx配置:
upstream app {
# Path to Unicorn SOCK file, as defined previously
server unix:/tmp/unicorn.my_domain.sock fail_timeout=0;
}
server {
listen 80;
server_name my_domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.rsa;
server_name my_domain.com;
root /var/www/current;
location /assets {
root /var/www/current/public;
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}问题
API请求(POST /api/some_path/create等)应该使用双向SSL进行保护。
只有一个服务将使用此API (只有一个客户端拥有一个证书)
问题
two-way SSL吗?two-way SSL应该在nginx层上实现,而不是在web应用逻辑中实现.我说的对吗?nginx以捕获向/api/... url发送请求的客户端,并使用two-way SSL对其进行身份验证我只需要一个基本的例子,来理解它应该如何工作。
发布于 2016-02-23 18:08:11
示例配置:
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.rsa;
ssl_client_certificate /etc/nginx/ssl/client_ca.pem;
ssl_verify_client on;
server_name api.my_domain.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app/api;
}
}发布于 2021-11-12 13:25:23
这个例子将向您介绍相互认证的世界。本教程向您介绍使用NGINX服务器配置双向安全性和连接网站的步骤。因此,我假设您对上述技术以及使用Bash和Docker都有一定的了解。
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│ │ │ │ │ │ │ │
│ Browser ├──────►│ nginx 1 ├──────►│ nginx 2 ├──────►│ Website │
│ │ HTTPS │ │ mTLS │ │ HTTPS │ │
└─────────┘ └─────────┘ └─────────┘ └─────────┘https://stackoverflow.com/questions/35574958
复制相似问题