- 论坛徽章:
- 0
|
想请教一下论坛里的高手
如何配置nginx去反向代理远端的https下的web服务器。下面是我的配置文件nginx.conf的内容,请大家指正
#cat nginx.conf
user nginx nginx;
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 4096;
# use kqueue;
}
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;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
tcp_nodelay on;
#send_lowat 12000;
keepalive_timeout 75 20;
upstream xp.test.com {
server 192.168.6.8:80;
}
server {
listen 80;
server_name 192.168.44.151;
root html;
#charset koi8-r;
charset utf-8;
access_log logs/host.access.log;
#location / {
# root html;
# index index.html index.htm index.php;
#}
location / {
proxy_pass http://xp.test.com;
proxy_set_header X-Real-IP $remote_addr;
}
if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
location /nginx_status {
stub_status on;
access_log off;
}
include enable_php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
error_page 497 "https://$host$uri?$args";
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
# root html;
# index index.html index.htm;
include proxy.conf;
auth_basic "status";
}
}
}
对上面的配置文件做一些基本的解释:我的nginx代理服务器ip地址为192.168.44.151,真实的服务器为192.168.6.8.现在的问题是,我的思路为用户请求到达nginx代理服务器的80端口后,代理将请求转发至远端web服务器的80端口(因为首页未加密,但首页上有进入被加密内容的链接),当用户在点击首页上被加密内容链接后便进入加密页面,即https。
以上的配置能够正常看到非加密内容,但是一旦点击含有加密内容的链接后,便会报错。内容为“无法显示该页面”,远端服务器的证书和私钥文件均已上传至这台nginx上
想问一下,上面的配置中是哪里配置的有问题呢?
附:
#cat proxy.conf
#proxy_set_header X-Forwarded-For $remote_addr;
#proxy_set_header REMOTE_ADDR $remote_addr;
#proxy_set_header RealIP $remote_addr;
proxy_set_header Host $proxy_host;
#proxy_set_header Accept-Encoding '';
#proxy_hide_header X-Cache;
#proxy_hide_header X-Powered-By;
#proxy_hide_header Last-Modified;
#proxy_hide_header Date;
#proxy_hide_header Content-Length;
#proxy_hide_header Content-Language;
#proxy_hide_header Cache-Control;
#proxy_pass_header Server;
client_max_body_size 8m;
proxy_connect_timeout 15s;
proxy_send_timeout 1m;
proxy_read_timeout 1m;
proxy_temp_file_write_size 1024m;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_ignore_client_abort on;
proxy_next_upstream error timeout invalid_header http_503; |
|