侧边栏壁纸
博主头像
Adrian博主等级

曙光在头上,不抬起头,便永远只能看见物质的闪光。

  • 累计撰写 108 篇文章
  • 累计创建 67 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Nginx 多虚拟主机配置以及SSL安全配置

Adrian
2021-12-15 / 0 评论 / 0 点赞 / 140 阅读 / 1,785 字
温馨提示:
本文最后更新于 2021-12-15,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

同一台Nginx服务配置多个 server_name

  • login.example.com
  • system.example.com
  • example.com
#禁止IP访问
server {
  listen 80 default;
  server_name _;
  return 403;
}


# login.example.com
server {
  #SSL configuration
  listen 443 ssl;
  listen [::]:443 ssl;

  server_name login.example.com;
  #ssl证书配置
  ssl_certificate "/xx/xx/ssl/a.pem";
  ssl_certificate_key "/xx/xx/ssl/a.key";
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout 10m;
  ssl_ciphers HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers on;

  #index.html
  location / {
    root /var/www/login.example.com/html;
    index index.html index.htm;
    try_files $uri $uri/ /index.html;
  }

  location /server {
    proxy_pass http://127.0.0.1:8080;
  }
}


# http 跳转 https
server {
  listen 80;
  server_name login.example.com;
  return 301 https://login.example.com$request_uri;
}


# system.example.com
server {
  #SSL configuration
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name system.example.com;

  ssl_certificate "/xx/xx/ssl/a.pem";
  ssl_certificate_key "/xx/xx/ssl/a.key";
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout 10m;
  ssl_ciphers HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers on;

  location / {
    root /var/www/system.example.com/html;
    index index.html index.htm;
    try_files $uri $uri/ /index.html;
  }

  location /server {
    proxy_pass http://127.0.0.1:8080;
  }
}


# http 跳转 https
server {
  listen 80;
  server_name system.example.com;
  return 301 https://system.example.com$request_uri;
}


#example.com
server {
  #SSL configuration
  listen 443 ssl default_server;
  listen [::]:443 ssl default_server;
  server_name example.com;

  ssl_certificate "/xx/xx/ssl/a.pem";
  ssl_certificate_key "/xx/xx/ssl/a.key";
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout 10m;
  ssl_ciphers HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers on;

  location / {
    root /var/www/example.com/html;
    index index.html index.htm;
    try_files $uri $uri/ /index.html;
  }
}


# http 跳转 https
server {
  listen 80;
  server_name example.com;
  return 301 https://www.example.com$request_uri;
}
0
博主关闭了当前页面的评论