我已经在我的服务器上安装并运行了一个Rails应用程序,现在我想再添加一个。
我想让Nginx检查请求是为了什么,并根据域名拆分流量
这两个站点都有自己的符号链接到启用站点的nginx.conf,但我在启动nginx Starting nginx: nginx: [emerg] duplicate listen options for 0.0.0.0:80 in /etc/nginx/sites-enabled/bubbles:6
时遇到错误
他们都在80上收听,但收听的是不同的东西。
站点#1
upstream blog_unicorn {
server unix:/tmp/unicorn.blog.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name walrus.com www.walrus.com;
root /home/deployer/apps/blog/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @blog_unicorn;
location @blog_unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://blog_unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
站点二:
upstream bubbles_unicorn {
server unix:/tmp/unicorn.bubbles.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name bubbles.com www.bubbles.com;
root /home/deployer/apps/bubbles/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @bubbles_unicorn;
location @bubbles_unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://bubbles_unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
发布于 2016-06-02 18:22:14
刚刚遇到了同样的问题,但重复的default_server
指令并不是导致此消息的唯一原因。
只能在其中一个server_name
指令上使用backlog
参数。
示例
站点1:
server {
listen 80 default_server backlog=2048;
server_name www.example.com;
location / {
proxy_pass http://www_server;
}
站点2:
server {
listen 80; ## NOT NOT DUPLICATE THESE SETTINGS 'default_server backlog=2048;'
server_name blogs.example.com;
location / {
proxy_pass http://blog_server;
}
发布于 2018-03-03 09:56:58
我也有同样的问题。我通过修改我的/etc/nginx/sites available/example2.com文件修复了这个问题。我将服务器块更改为
server {
listen 443 ssl; # modified: was listen 80;
listen [::]:443; #modified: was listen [::]:80;
. . .
}
在/etc/nginx/sites available/example1.com中,我注释掉了listen 80
和listen [::]:80
,因为服务器块已经配置为443。
https://stackoverflow.com/questions/13676809
复制相似问题