- 論壇徽章:
- 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端口后,代理將請求轉發(fā)至遠端web服務器的80端口(因為首頁未加密,但首頁上有進入被加密內容的鏈接),當用戶在點擊首頁上被加密內容鏈接后便進入加密頁面,即https。
以上的配置能夠正?吹椒羌用軆热荩且坏c擊含有加密內容的鏈接后,便會報錯。內容為“無法顯示該頁面”,遠端服務器的證書和私鑰文件均已上傳至這臺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; |
|