首页 新闻 会员 周边

windows下nginx反向代理失败

0
悬赏园豆:20 [已解决问题] 解决于 2017-03-28 03:34

想在windows环境下简单配置一个nginx代理,请教各位大神帮忙看看什么问题,配置如下图

 

WinJohn的博客的主页 WinJohn的博客 | 初学一级 | 园豆:70
提问于:2017-02-07 15:56
< >
分享
最佳答案
0
  1 #user  nobody;
  2 worker_processes  2; #nginx进程数,建议设置为等于CPU总核心数
  3 #worker_rlimit_nofile 10240;
  4 #error_log  logs/error.log;
  5 #error_log  logs/error.log  notice;
  6 #error_log  logs/error.log  info;
  7 
  8 #pid        logs/nginx.pid;
  9 
 10 
 11 events {
 12     worker_connections  1024; #单个进程最大连接数(最大连接数=连接数*进程数)
 13 }
 14 
 15 
 16 http {
 17     include       mime.types;
 18     default_type  application/octet-stream;
 19     proxy_buffering off;
 20 
 21     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 22     #                  '$status $body_bytes_sent "$http_referer" '
 23     #                  '"$http_user_agent" "$http_x_forwarded_for"';
 24 
 25     #access_log  logs/access.log  main;
 26 
 27     sendfile        on;
 28     server_tokens off;
 29     client_max_body_size    100m;
 30     #tcp_nopush     on;
 31 
 32     #keepalive_timeout  0;
 33     keepalive_timeout  65;
 34 
 35         client_header_buffer_size 4k;
 36         open_file_cache max=10240 inactive=20s;
 37         open_file_cache_valid 30s;
 38         open_file_cache_min_uses 1;
 39     #gzip  on;
 40 
 41     #服务器集群名称为Jq_one
 42     upstream 10.10.45.39 {
 43         ip_hash;  #ip 划分用户
 44         #fair;
 45         server  10.10.45.39:8010;  
 46         server  10.10.45.39:8011;
 47     }
 48 
 49     server {
 50         listen       8080;
 51         server_name  10.10.45.39;
 52 
 53         #charset koi8-r;
 54 
 55         #access_log  logs/host.access.log  main;
 56 
 57         location / {
 58             root   html;
 59             index  index.aspx index.html index.htm;
 60         #指向集群名称为Jq_one
 61         proxy_pass         http://10.10.45.39/; 
 62             proxy_connect_timeout 10s;
 63         #设置主机头和客户端真实地址,以便服务器获取客户端真实IP
 64         proxy_set_header   Host             $host; 
 65         proxy_set_header   X-Real-IP        $remote_addr; 
 66         proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
 67         }
 68 
 69     #静态资源缓存设置
 70     #location ~ \.(jpg|png|jpeg|bmp|gif|swf|css)$
 71         #{ 
 72         #    expires 30d;
 73         #    root /nginx-1.9.3/html;#root:
 74         #    break;
 75         #}
 76 
 77 
 78         #error_page  404              /404.html;
 79 
 80         # redirect server error pages to the static page /50x.html
 81         #
 82         error_page   500 502 503 504  /50x.html;
 83         location = /50x.html {
 84             root   html;
 85         }
 86 
 87         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
 88         #
 89         #location ~ \.php$ {
 90         #    proxy_pass   http://127.0.0.1;
 91         #}
 92 
 93         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 94         #
 95         #location ~ \.php$ {
 96         #    root           html;
 97         #    fastcgi_pass   127.0.0.1:9000;
 98         #    fastcgi_index  index.php;
 99         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
100         #    include        fastcgi_params;
101         #}
102 
103         # deny access to .htaccess files, if Apache's document root
104         # concurs with nginx's one
105         #
106         #location ~ /\.ht {
107         #    deny  all;
108         #}
109     }
110 
111 
112     # another virtual host using mix of IP-, name-, and port-based configuration
113     #
114     #server {
115     #    listen       8000;
116     #    listen       somename:8080;
117     #    server_name  somename  alias  another.alias;
118 
119     #    location / {
120     #        root   html;
121     #        index  index.html index.htm;
122     #    }
123     #}
124 
125 
126     # HTTPS server
127     #
128     #server {
129     #    listen       443 ssl;
130     #    server_name  localhost;
131 
132     #    ssl_certificate      cert.pem;
133     #    ssl_certificate_key  cert.key;
134 
135     #    ssl_session_cache    shared:SSL:1m;
136     #    ssl_session_timeout  5m;
137 
138     #    ssl_ciphers  HIGH:!aNULL:!MD5;
139     #    ssl_prefer_server_ciphers  on;
140 
141     #    location / {
142     #        root   html;
143     #        index  index.html index.htm;
144     #    }
145     #}
146 
147 }

以上是我的配置,以前测试过的,你看看。

收获园豆:20
Vancen | 初学一级 |园豆:80 | 2017-02-07 16:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册