Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nginx简单SSL连接_Ssl_Nginx - Fatal编程技术网

nginx简单SSL连接

nginx简单SSL连接,ssl,nginx,Ssl,Nginx,我不熟悉使用nginx设置简单的SSL连接。我在下面编写的代码是可以访问的,但它没有使用SSL运行。我错过了什么 我的测试站点只是一个简单的index.html。我的证书和密钥保存在/etc/ssl/certs中 server { listen 80; server_name example.com; location / { proxy_pass https://example.com:443; } }

我不熟悉使用nginx设置简单的SSL连接。我在下面编写的代码是可以访问的,但它没有使用SSL运行。我错过了什么

我的测试站点只是一个简单的
index.html
。我的证书和密钥保存在
/etc/ssl/certs

 server {
     listen 80;
     server_name             example.com;

     location / {
         proxy_pass https://example.com:443;
     }
 }

 server {
     listen 443;
     root                    /home/deploy/test;

     ssl on;
     ssl_certificate      /etc/ssl/certs/server.crt;
     ssl_certificate_key  /etc/ssl/certs/server.key;
 }

您必须将非HTTPS重定向到HTTPS,而不是代理传递

server {
  listen 80;
  server_name example.com;
  return 301 https://example.com$request_uri;
}
server {
  listen 443;
  server_name example.com;
  root                    /home/deploy/test;

  ssl on;
  ssl_certificate      /etc/ssl/certs/server.crt;
  ssl_certificate_key  /etc/ssl/certs/server.key;
}
.