【发布时间】:2019-03-28 10:49:31
【问题描述】:
我有一个 tomcat 服务器,目前在端口 8082(http) 上运行。我必须在不触及服务器代码或 tomcat 配置的情况下创建站点 https。我安装了 nginx 并且可以将 https 重定向到 http,但浏览器仍然说站点不安全。我们怎样才能让客户端使用https,然后nginx内部重定向到http,但是对客户端所有的调用都是https。
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name localhost;
location / {
proxy_pass "http://localhost:8082/app/";
}
}
server {
listen 443 ssl;
server_name localhost;
ssl_certificate nginx-selfsigned.crt;
ssl_certificate_key nginx-selfsigned.key;
rewrite ^(.*) http://localhost:8082/app$1 permanent;
}
}
【问题讨论】:
-
您正在寻找的是反向代理,这是在 Nginx 中使用
proxy_pass实现的。
标签: nginx