LoginSignup
0
1

More than 3 years have passed since last update.

「a duplicate default server for 0.0.0.0:80」という nginx問題の解決方法

Last updated at Posted at 2020-06-13

同じNGINX サーバーで、二つのサイトを立ち上がりたいところでした。

sugoi.website.net
website.net

上記の二つドメインです。

/etc/nginx/sites-available/

上記のフォルダーにコンフィグファイルも設置しました。nginx サーバー再起動したら、以下エラー出ました;

: a duplicate default server for 0.0.0.0:80 in /etc/nginx/sites-enabled/default:2

各ドメインのコンフィグファイルです

どうやら、ipv6only=on と default_server は二つ記載されているのはダメでした。

片方で削除してみたら問題なく動けます

server {
    server_name sugoi.website.net
        #listen 80 default_server; <----問題1
        listen 80;
        #listen [::]:80 default_server ipv6only=on; <----問題2
        root  /var/www/html/sugoi.website/public;
        passenger_enabled on;
        passenger_ruby /home/ubuntu/.rvm/gems/ruby-2.6.6/wrappers/ruby;
        rails_env production;
    client_max_body_size 100m;

        location ^~ /assets/ {
            access_log off;
            gzip_static on;
            expires 0;
            add_header Cache-Control public;
            add_header ETag "";
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Request-Method *;
        }


    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

}
server {
        server_name www.website.com;
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on; <--問題
        root  /var/www/html/website/public;
        passenger_enabled on;
        passenger_ruby /home/ubuntu/.rvm/gems/ruby-2.6.6/wrappers/ruby;
        rails_env production;

    client_max_body_size 100m;

        location ^~ /assets/ {
            access_log off;
            gzip_static on;
            expires 0;
            add_header Cache-Control public;
            add_header ETag "";
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Request-Method *;
        }


    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;
}

問題のところがコメントアウトしてみたら、動いてくれました。

忘れなく

service nginx restart

or

service nginx reload

しましょう

以上

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1