首先,对不起我的英语(T^T)
我想运行三个应用程序。
(实际上,有一个应用程序。唯一的区别是环境(开发、分期、生产)
所以我修改了一些密码。
但只在80个港口工作!
如果我在工作时将服务器端口(监听80)更改为81,则在端口81 T^T上不能工作。
我不知道为什么它只工作在80个端口上
这是我的my_app_nginx.conf,deploy.rb,unicorn.rb,unicorn_init.sh,netstat-lnp
/etc/nginx/sites-enabled/my_app_nginx (它包括nginx.conf)
三次上升。和三台服务器的监听端口80(生产),3000(开发),3001(分期)
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
upstream unicorn_development {
server unix:/tmp/unicorn.chimiseng_development.sock fail_timeout=0;
}
upstream unicorn_staging {
server unix:/tmp/unicorn.chimiseng_staging.sock fail_timeout=0;
}
upstream unicorn_production {
server unix:/tmp/unicorn.chimiseng_production.sock fail_timeout=0;
}
server {
listen 80;
root /bps_data/apps/chimiseng_production/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn_production;
location @unicorn_production {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_production;
}
error_page 500 502 503 504 /500.html;
error_log /bps_data/apps/chimiseng_production/shared/log/nginx_error.log warn;
access_log /bps_data/apps/chimiseng_production/shared/log/nginx_access.log compression;
client_max_body_size 4G;
keepalive_timeout 10;
}
server {
listen 3000;
root /bps_data/apps/chimiseng_development/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn_development;
location @unicorn_development {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_development;
}
error_page 500 502 503 504 /500.html;
error_log /bps_data/apps/chimiseng_development/shared/log/nginx_error.log warn;
access_log /bps_data/apps/chimiseng_development/shared/log/nginx_access.log compression;
client_max_body_size 4G;
keepalive_timeout 10;
}
server {
listen 3001;
root /bps_data/apps/chimiseng_staging/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn_staging;
location @unicorn_staging {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_staging;
}
error_page 500 502 503 504 /500.html;
error_log /bps_data/apps/chimiseng_staging/shared/log/nginx_error.log warn;
access_log /bps_data/apps/chimiseng_staging/shared/log/nginx_access.log compression;
client_max_body_size 4G;
keepalive_timeout 10;
}供参考..。domain.com:80记录在nginx_access_log
但是,domain.com:3000或:3001从未在nginx_access_log上登录。只留下0字节。
unicorn.rb
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
root = "/bps_data/apps/chimiseng_#{environment}/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.chimiseng_#{environment}.sock"
worker_processes 2
timeout 30deploy.rb
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command} #{rails_app}"
end
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/chimiseng"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
end
...
...unicorn_init.sh
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/bps_data/apps/chimiseng_$2/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E $2"
... start|stop|force-stop|restart... codes...netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
...
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:3001 0.0.0.0:* LISTEN -
...
Active UNIX domain sockets (only servers)
...
unix 2 [ ACC ] STREAM LISTENING 9525914 8564/unicorn.rb -E /tmp/unicorn.chimiseng_development.sock
unix 2 [ ACC ] STREAM LISTENING 9509620 13448/unicorn.rb -E /tmp/unicorn.chimiseng_staging.sock
unix 2 [ ACC ] STREAM LISTENING 9519355 3020/unicorn.rb -E /tmp/unicorn.chimiseng_production.sock
...我试图"nginx重新启动“和sh -c”/etc/init.d/unicorn_嵌合体_ENVIRONMENT重新启动环境“无法工作。
但是你可以看到netstat -lnp。听好端口,袜子是活动的。
在nginx的“聆听”中没有默认的延迟选项。
为什么不能使用80以外的端口??
请帮帮我
发布于 2014-09-24 07:55:15
对不起T^T
我解决了这个问题。
我用的是云服务器。
突然间,我想到了云服务器网站中的forwarding。
考虑到网站中的3000,3001端口。效果不错.!
每个人点击不清楚的问题..。很抱歉看了这个问题。X(
祝您今天愉快!
https://stackoverflow.com/questions/26010211
复制相似问题