nginx 代理http转https
来源:互联网 发布:郑智化IT 编辑:程序博客网 时间:2024/05/20 18:40
前言:采用了nginx +nginx 两台服务器的方式获取 客户端的真实IP。
具体配置可参考之前的文摘!
这里需要做到这样的功能,前端nginx 使用http代理 (https 好像无法实现转发) 链接到后端的https 网站!
nginx支持https ,可参考前面的文摘!
要使客户端连接的http请求 转发到后端的web服务器上,前端的nginx,具体配置如下:
[root@iZbp1c3lxfxbdfeq8fpjadZ nginx]# cat nginx.conf
#user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
#use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
server {
listen 10080;
proxy_redirect off;
location / {
proxy_set_header Host \$host;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header X-Forwarded-Host \$server_name;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP \$remote_addr;
real_ip_header X-Real-IP;
proxy_pass https://后端server的IP地址;
}
}
}
后端的nginx的配置如下:
[root@iZbp1g56n6ff2bh6b213xwZ:/etc/nginx]#cat nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl;
server_name localhost;
real_ip_header X-Real-IP;
# set_real_ip_from 192.168.10.0/24;
set_real_ip_from 前端server的IP地址;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
location / {
root /server/php;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /server/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
- nginx 代理http转https
- nginx 反向代理http/https
- Nginx同时反向代理http和https
- Nginx同时反向代理http和https
- Nginx实现http转https
- nginx下http转https
- http转https(nginx)
- nginx http请求转https
- CentOS云主机中Nginx正向代理http、https
- Nginx 反向代理https
- Nginx代理https跳转
- nginx 代理https后,spring mvc web应用redirect https变成http
- HTTP转HTTPS,Linux下配置Nginx
- 用 Nginx 实现 https 转 http
- Nginx下的项目 http转https
- 用Nginx实现https转http
- nginx配置https代理tomcat
- nginx 反向代理https配置
- Java语言基础
- mac eclipse EDT C++以及symbol 'std' could not be resolved问题的解决
- 看看腾讯和百度等这样的大型网站系统架构是如何演化的
- CocoaPods创建自己的pod
- ubuntu14.04下设置静态IP
- nginx 代理http转https
- WiFi Throughput summary
- TCP服务器端、客户端模式初文
- 技术博客园系统开发设计总结
- php的强制转换
- java 手写服务器
- 3Spring Boot 运行原理,自动配置
- c#多线程
- 如何把数组做为一个字段存入存入数据库