赞,顶
还有个怪事,我有两个域名 a.com,b.com,pat.a.com,pat.b.com 都解析到这个 ip,但是 nginx 里只配 pat.a.com,两个访问都是 403,也都导向 root 目录了,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;
}
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 后正常运行 又碰到新问题,原因未研究
论坛,stackoverflow 的 case 都看过了,都没解决。。
补充:在 public 下放/index.html 能正常访问到
@Rei 求指导,搜几天了,实在解决不了。。
同样碰到 403 问题了,请@Rei @jialezhang 帮看看 直接 rails s 启动可以正常 ip 访问 感觉 server_name pattest.domain1.com;并未生效,通过http://pattest.domain1.com:3000/http://pattest.domain2.com:3000/访问都是403或者
配置: 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; }
nginx log: 2014/05/23 23:04:36 [error] 35484#0: *4 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:3000"
ror public: drwxr-xr-x 3 lpxiao lpxiao 4096 May 23 22:33 public
#12 楼 @sunday35034 多谢,按这个步骤搞下,sunday 当初怎么处理的 min.css min.js,直接用的?
#6 楼 @leekelby @sunday35034 多谢指点,没有看到未压缩 css,ace 都是带 min 的,暂定还是一步步来,先学习 ruby-china 的前端展示
阿里云 OTS,OCS 腾讯云 CMEM Ucloud UMem
OCS CMEM UMem 较贵,适合热点数据
赞,有机会用用
#7 楼 @xiaoniuniu 最后怎么用起来的?同遇到。。
新手上路中,打算先找个基于 bootstrap 的模版入门
愣,在 lz 大学同学后面发现了 ustc..
#2 楼 @blacktulip 请问定时任务如何调用 rails 中的 controller,model 方法?
#7 楼 @small_fish__ 用的啥方法?Net::POP3?