相关疑难解决方法(0)

如何使用 nginx 作为具有多个 IP 和 SSL 的反向代理?

我想设置具有多个域和 IP 的 nginx 反向代理,以便每个域使用不同的 SSL 证书。我将 Ubuntu 作为操作系统运行,该操作系统安装在 KVM/Qemu VM 上。

据我了解 nginx,它应该能够通过一个 IP 为一个域(以及属于它的子域)提供服务。但我无法让它运行......

这是我的 nginx 配置:

/etc/nginx/sites-enabled/my_first_domain

server {
  listen x.x.x.84:80;                                   # this is a public ip
  server_name firstdomain.com;

  access_log /var/log/nginx/access.log proxy;     # I made my own logformat
  error_log  /var/log/nginx/error.log;

  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Client-IP $remote_addr;
  proxy_set_header X-Host $host;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $remote_addr;

  location / {
    rewrite ^/(.*) https://firstdomain/$1;  # redirect to https
  }
}

server {
  listen x.x.x.84:443 ssl;                            # this is a public …
Run Code Online (Sandbox Code Playgroud)

ssl nginx https reverse-proxy

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

https ×1

nginx ×1

reverse-proxy ×1

ssl ×1