• 赞,顶

  • #6楼 @Guest 有意跳槽不?

  • #16楼 @Rei 多谢rei,连上了 @huacnlee 找时间把环境用户权限好好学学

  • 还有个怪事,我有两个域名a.com,b.com,pat.a.com,pat.b.com都解析到这个ip,但是nginx里只配pat.a.com,两个访问都是403,也都导向root目录了,nginx没过滤我的域名?

  • #11楼 @ruohanc nginx配置没动过

    cat /etc/nginx/nginx.conf 
    user www-data;
    worker_processes 4;
    pid /var/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;
    #       }
    # }
    

    按文档加的

    cat /etc/nginx/sites-enabled/example.com.conf 
    server {
        listen 80 default;
        #listen 3000;
        server_name pattest.domain1.com;
        root /var/www/pattest.domain1.com/pat/public;
        passenger_ruby /home/lpxiao/.rvm/rubies/ruby-2.1.0/bin/ruby;
        passenger_enabled on;
    }
    
  • #11楼 @ruohanc

    1. shell ps -ef| grep nginx root 45240 1 0 21:02 ? 00:00:00 nginx: master process /usr/sbin/nginx www-data 45241 45240 0 21:02 ? 00:00:00 nginx: worker process www-data 45242 45240 0 21:02 ? 00:00:00 nginx: worker process www-data 45243 45240 0 21:02 ? 00:00:00 nginx: worker process www-data 45244 45240 0 21:02 ? 00:00:00 nginx: worker process lpxiao 45454 43362 0 21:23 pts/1 00:00:00 grep --color=auto nginx
    cat /etc/nginx/nginx.conf | grep user
    user www-data;
    

    2.

    sudo -u www-data ls /var/www/pattest.domain1.com/pat/public/
    [sudo] password for lpxiao: 
    404.html  422.html  500.html  assets  favicon.png  robots.txt
    

    3.

    sudo chown www-data: -R public/
    [sudo] password for lpxiao: 
    
    ll | grep public
    drwxr-xr-x  3 www-data www-data  4096 May 24 21:11 public/
    

    log,偶发报favicon.ico,不知啥原因

    2014/05/24 21:33:10 [error] 45241#0: *12 open() "/var/www/pattest.domain1.com/pat/public/favicon.ico" failed (2: No such file or directory), client: 123.114.36.75, server: pattest.domain1.com, request: "GET /favicon.ico HTTP/1.1", host: "pattest.domain2.cn"
    2014/05/24 21:33:44 [error] 45241#0: *16 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com"
    2014/05/24 21:34:38 [error] 45241#0: *16 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com"
    2014/05/24 21:35:49 [error] 45241#0: *18 directory index of "/var/www/pattest.domain1.com/pat/public/" is forbidden, client: 123.114.36.75, server: pattest.domain1.com, request: "GET / HTTP/1.1", host: "pattest.domain1.com"
    
  • 来结贴: 今天使用root登录pg失败同样报错PG::ConnectionBad (FATAL: Peer authentication failed for user "lpxiao" 增加 -h 之后成功登录 故在database.yml的host填写localhost后正常运行 又碰到新问题,原因未研究

  • #8楼 @ruohanc 再看下?

    1. 运营用户是user www-data;;
    2. 可以正常ls
    3. 没有用 public下面如果有index.html是可以正常访问的,看nginx日志就是public无权限,public +777和改owner都没有用
  • #5楼 @Rei 能经验的给一些调试思路吗?现在是加autoindex on;能正常访问目录;增加Index.html文件也能访问到,同时如果用的是另一个非nginx conf中配置的域名也能访问到

junior rubyist,大家多关照 做过项目:CMEM/CKV(8000台集群),CRedis,CMongoDB,嘀嘀打车LBS,财付通Cache层异地复制;对数据一致性,数据持久化,服务可用性,高并发,可扩展,容灾切换,自动运维的分布式系统有多年架构和运营经验,欢迎交流。