• @zoker 看了一下 druby,让人眼前一亮 😄

  • :plus1:

  • @flyerhzm 看了英文的 blog,好像有个 typo?

  • 很明显阅读起来非常简单

  • 01 的配置里面还有一个

    upstream balance {
          server  xx.xx.xx.02:80;
      }
    
  • @gazeldx 我老家是江苏的,现在在成都,目前挺符合你们要求,哈哈

  • @lite 到处在抢人啊 😃

  • 不用 rails 不就不纠结这个问题了 ==!

  • 写 Block 的一些小结 at 2015年06月11日

    :thumbsup: 不错呀

  • @juanito 英语六级,https://github.com/Ailenswpu, i will try my best

  • @gazeldx 哈哈,reactnative 不错哟

  • go fucking do it

  • @small_fish__ chrome 自带这个功能,Inspect Element 之后有个手机的 icon,可以选择机型

  • @wuwx 就当没有 AR,前辈们在没有 AR 的时候如果遇到这种需求咋办呢?

  • @huacnlee 问题已经解决,是我自己犯了错误,load balancer 配置是 ok 的,但是两个 app server 把默认的配置没有删除,所以一直返回 nginx 的欢迎页面。非常感谢你。

  • @huacnlee 这个是 nginx 目录的 tree

    ├── win-utf
    ├── uwsgi_params
    ├── sites-enabled
    │   └── slots-load-balancer
    ├── sites-available
    │   └── default
    ├── scgi_params
    ├── proxy_params
    ├── nginx.conf
    ├── naxsi-ui.conf.1.4.1
    ├── naxsi.rules
    ├── naxsi_core.rules
    ├── mime.types
    ├── koi-win
    ├── koi-utf
    ├── fastcgi_params
    └── conf.d
    

    配置文件只有 sites_enabled 下面的 slots-load-balancer。这个问题找了好久,还是没有解决。

  • @huacnlee 107.170.216.243 这条机器所有的配置如下:

    /etc/nginx/nginx.conf
    
    user www-data;
    worker_processes 4;
    pid /run/nginx.pid;
    
    events {
        worker_connections 768;
        # multi_accept on;
    }
    
    http {
    
        ##
        # Basic Settings
        ##
    
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;
    
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
    
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
    
        ##
        # Logging Settings
        ##
    
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
    
        ##
        # Gzip Settings
        ##
    
        gzip on;
        gzip_disable "msie6";
    
        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##
    
        # include /etc/nginx/naxsi_core.rules;
    
        ##
        # Phusion Passenger config
        ##
        # Uncomment it if you installed passenger or passenger-enterprise
        ##
    
        # passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
        # passenger_ruby /usr/bin/ruby;
    
        ##
        # Virtual Host Configs
        ##
    
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    }
    
    
    # mail {
    #   # See sample authentication script at:
    #   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    #
    #   # auth_http localhost/auth.php;
    #   # pop3_capabilities "TOP" "USER";
    #   # imap_capabilities "IMAP4rev1" "UIDPLUS";
    #
    #   server {
    #       listen     localhost:110;
    #       protocol   pop3;
    #       proxy      on;
    #   }
    #
    #   server {
    #       listen     localhost:143;
    #       protocol   imap;
    #       proxy      on;
    #   }
    # }
    
    /etc/nginx/sites-enabled/slots-load-balancer
    upstream backend  {
      server 192.241.225.37;
      server 192.241.207.103;
    }
    
    server {
      listen 80;
      server_name 107.170.216.243;
      location / {
        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   X-Forwarded-Host $host;
        proxy_set_header   X-Forwarded-Server $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_buffering    on;
        proxy_pass  http://backend;
        access_log /var/log/nginx/proxy.log;
        #proxy_http_version 1.1;
        #proxy_set_header Connection "";
      }
    }
    

    另外/etc/nginx/sites-enabled/default 已经被我删除,不会产生影响

  • @huacnlee nginx 已经重启了,配置没有问题。 在 107.170.216.243 这台机器访问curl http://192.241.225.37返回如下:

    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","errorBeacon":"bam.nr-data.net","licenseKey":"f96debd018","applicationID":"8067875","transactionName":"elpYRRBeCFkAQx4UBlVWWVwHHg1bAVRJ","queueTime":0,"applicationTime":46,"ttGuid":"","agentToken":null,"agent":"js-agent.newrelic.com/nr-632.min.js"}</script>
    <script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(e,n,t){function r(t){if(!n[t]){var o=n[t]={exports:{}};e[t][0].call(o.exports,function(n){var o=e[t][1][n];return r(o?o:n)},o,o.exports)}return n[t].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<t.length;o++)r(t[o]);return r}({QJf3ax:[function(e,n){function t(e){function n(n,t,a){e&&e(n,t,a),a||(a={});for(var u=c(n),f=u.length,s=i(a,o,r),p=0;f>p;p++)u[p].apply(s,t);return s}function a(e,n){f[e]=c(e).concat(n)}function c(e){return f[e]||[]}function u(){return t(n)}var f={};return{on:a,emit:n,create:u,listeners:c,_events:f}}function r(){return{}}var o="nr@context",i=e("gos");n.exports=t()},{gos:"7eSDFh"}],ee:[function(e,n){n.exports=e("QJf3ax")},{}],3:[function(e,n){function t(e){return function(){r(e,[(new Date).getTime()].concat(i(arguments)))}}var r=e("handle"),o=e(1),i=e(2);"undefined"==typeof window.newrelic&&(newrelic=window.NREUM);var a=["setPageViewName","addPageAction","setCustomAttribute","finished","addToTrace","inlineHit","noticeError"];o(a,function(e,n){window.NREUM[n]=t("api-"+n)}),n.exports=window.NREUM},{1:12,2:13,handle:"D5DuLP"}],"7eSDFh":[function(e,n){function t(e,n,t){if(r.call(e,n))return e[n];var o=t();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(e,n,{value:o,writable:!0,enumerable:!1}),o}catch(i){}return e[n]=o,o}var r=Object.prototype.hasOwnProperty;n.exports=t},{}],gos:[function(e,n){n.exports=e("7eSDFh")},{}],handle:[function(e,n){n.exports=e("D5DuLP")},{}],D5DuLP:[function(e,n){function t(e,n,t){return r.listeners(e).length?r.emit(e,n,t):(o[e]||(o[e]=[]),void o[e].push(n))}var r=e("ee").create(),o={};n.exports=t,t.ee=r,r.q=o},{ee:"QJf3ax"}],id:[function(e,n){n.exports=e("XL7HBI")},{}],XL7HBI:[function(e,n){function t(e){var n=typeof e;return!e||"object"!==n&&"function"!==n?-1:e===window?0:i(e,o,function(){return r++})}var r=1,o="nr@id",i=e("gos");n.exports=t},{gos:"7eSDFh"}],G9z0Bl:[function(e,n){function t(){var e=d.info=NREUM.info,n=f.getElementsByTagName("script")[0];if(e&&e.licenseKey&&e.applicationID&&n){c(p,function(n,t){n in e||(e[n]=t)});var t="https"===s.split(":")[0]||e.sslForHttp;d.proto=t?"https://":"http://",a("mark",["onload",i()]);var r=f.createElement("script");r.src=d.proto+e.agent,n.parentNode.insertBefore(r,n)}}function r(){"complete"===f.readyState&&o()}function o(){a("mark",["domContent",i()])}function i(){return(new Date).getTime()}var a=e("handle"),c=e(1),u=(e(2),window),f=u.document,s=(""+location).split("?")[0],p={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-632.min.js"},d=n.exports={offset:i(),origin:s,features:{}};f.addEventListener?(f.addEventListener("DOMContentLoaded",o,!1),u.addEventListener("load",t,!1)):(f.attachEvent("onreadystatechange",r),u.attachEvent("onload",t)),a("mark",["firstbyte",i()])},{1:12,2:3,handle:"D5DuLP"}],loader:[function(e,n){n.exports=e("G9z0Bl")},{}],12:[function(e,n){function t(e,n){var t=[],o="",i=0;for(o in e)r.call(e,o)&&(t[i]=n(o,e[o]),i+=1);return t}var r=Object.prototype.hasOwnProperty;n.exports=t},{}],13:[function(e,n){function t(e,n,t){n||(n=0),"undefined"==typeof t&&(t=e?e.length:0);for(var r=-1,o=t-n||0,i=Array(0>o?0:o);++r<o;)i[r]=e[n+r];return i}n.exports=t},{}]},{},["G9z0Bl"]);</script>
      <title>SlotsServer</title>
      <link data-turbolinks-track="true" href="/assets/application-de4b8a4baeea040c0602c2f3ae77ff57.css" media="all" rel="stylesheet" />
      <script data-turbolinks-track="true" src="/assets/application-79b779fc5fcc60ab524424af69a14fdf.js"></script>
      <meta content="authenticity_token" name="csrf-param" />
    <meta content="dAr/Sxe0y55DZkH4AAA6FWxaqLpLgoPWXZy9Wfqqw8Q=" name="csrf-token" />
    </head>
    <body>
    
    hello
    
    </body>
    </html>
    

    是正常的结果。

  • @huacnlee 最新的配置文件为

    upstream backend  {
      server 192.241.225.37;
      server 192.241.207.103;
    }
    
    server {
      listen 80;
      server_name 107.170.216.243;
      location / {
        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   X-Forwarded-Host $host;
        proxy_set_header   X-Forwarded-Server $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_buffering    on;
        proxy_pass  http://backend;
        access_log /var/log/nginx/proxy.log;
        #proxy_http_version 1.1;
        #proxy_set_header Connection "";
      }
    }
    

    前面也没有server { .. }现在还是显示 nginx 的默认页面!

  • #7 楼 @huacnlee 好的,非常感谢,我马上看看

  • @huacnlee 192.241.225.37、192.241.207.103 是两个独立的 app server,环境是 rails + passenger,107.170.216.243 只装有 nginx,用来做 nginx 的 load balancer。我是直接访问 107.170.216.243 只出现了 nginx 的欢迎页面。

  • @huacnlee

    server {
      listen 80;
      server_name 107.170.216.243;
      location / {
        proxy_pass  http://backend;
        access_log /var/log/nginx/proxy.log;
        #include /etc/nginx/proxy_params;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
      }
    }
    
    upstream backend  {
      server 192.241.225.37;
      server 192.241.207.103;
    }
    

    这个是现在完整的配置

  • @huacnlee 具体的表现是 appserver 已经收到了 load balancer 发过来的请求,但是 load balancer 还是只出现 ngxin 的欢迎页面,具体的日志如下:比如我从浏览器访问 load balancer, load balancer 的访问日志如下:

    125.71.203.92 - - [27/Apr/2015:22:12:32 -0400] "GET / HTTP/1.1" 200 396 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
    

    app server 的访问日志如下:

    107.170.216.243 - - [27/Apr/2015:22:12:32 -0400] "GET / HTTP/1.1" 200 396 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"
    

    收到了请求,但是浏览器始终返回 nginx 的欢迎界面. 请帮我看看

  • @linuxgit

    irb(main):042:0> p "Daniel".object_id  == "Daniel".object_id
    false
    

    如果换成

    s = "Daniel"
    s.my_attr = "ruby"
    p s.my_attr
    

    就是对的

    附上链接:http://ruby-doc.org/core-2.2.2/Object.html#method-i-object_id

  • 告诉大家一个不幸的消息 at 2015年04月01日

    @lips 跟老师关系搞好就行了,哈哈

  • 告诉大家一个不幸的消息 at 2015年04月01日

    @lips 老板知道的,不管的,他忙得很,不过话说回来在学校纯粹是浪费时间

  • 告诉大家一个不幸的消息 at 2015年03月30日

    @lips 研二

  • 告诉大家一个不幸的消息 at 2015年03月29日

    @lips 差不多,老师也是水的,跟老师说明情况就好,不过这个看每个老师的性格,good luck to u!!

  • @karloku OK, thank U