<html><head></head><body style="zoom: 0%;"><div dir="auto">The error is self explanatory. You have two default_server entries that end up listening on port 80 on all IPs.<br><br></div>
<div dir="auto">listen 80 default_server;<br></div>
<div dir="auto">listen [::]:80 default_server;<br><br></div>
<div dir="auto">As configured this ends up listening on every port 80 on all IPs. Remove one of these to resolve the error.<br><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->Get <!-- tmjah_g_1299e --><a href="http://www.bluemail.me/r?b=16696"><!-- tmjah_g_1299s -->BlueMail for Android<!-- tmjah_g_1299e --></a><!-- tmjah_g_1299s --> <!-- tmjah_g_1299e --></div>
<div style="font-size:10.0pt;font-family:"Tahoma","sans-serif";padding:3.0pt 0in 0in 0in">
<hr style="border:none;border-top:solid #E1E1E1 1.0pt">
<b>From:</b> raphy <nginx-forum@forum.nginx.org><br>
<b>Sent:</b> Sat May 22 10:10:01 EDT 2021<br>
<b>To:</b> nginx@nginx.org<br>
<b>Subject:</b> What's the problem with this nginx configuration?<br>
</nginx-forum@forum.nginx.org></div>
<br>
<pre class="blue">Hi!!<br><br>Due to some issues in packages installed which caused the freezing of the<br>system, I had to re-install Ubuntu from scratch.<br><br>Now the previous nginx configuration, which previously worked fine, gives<br>this error:<br><br> ginx: [emerg] a duplicate default server for 0.0.0.0:80 in<br>/etc/nginx/conf.d/default.conf:54<br> nginx: configuration file /etc/nginx/nginx.conf test failed<br><br><br>This is /etc/nginx/conf.g/default.conf : <br><br>server {<br> listen 443 ssl http2 default_server;<br> server_name grasp.deals;<br> ssl_certificate /etc/letsencrypt/live/grasp.deals/fullchain.pem; #<br>managed by Certbot<br> ssl_certificate_key /etc/letsencrypt/live/grasp.deals/privkey.pem; #<br>managed by Certbot<br><br> ssl_trusted_certificate /etc/letsencrypt/live/grasp.deals/chain.pem;<br><br> ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot<br><br> ssl_session_timeout 5m;<br> ssl_protocols TLSv1.2 TLSv1.3;<br> ssl_ciphers<br>EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;<br> ssl_prefer_server_ciphers on;<br> ssl_session_cache shared:SSL:50m;<br> #ssl_stapling on;<br> #ssl_stapling_verify on;<br><br> access_log /var/log/nginx/graspdeals-access.log combined;<br><br> add_header Strict-Transport-Security "max-age=31536000";<br> location = /favicon.ico { access_log off; log_not_found off; }<br><br> location / {<br> proxy_pass <a href="http://127.0.0.1:8080">http://127.0.0.1:8080</a>;<br> proxy_http_version 1.1;<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection "upgrade";<br> #proxy_set_header Host $host;<br> }<br><br> # <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files">http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files</a><br> #<br><a href="https://unix.stackexchange.com/questions/585963/nginx-configuration-how-to-load-static-files-other-than-index-html/586567#586567">https://unix.stackexchange.com/questions/585963/nginx-configuration-how-to-load-static-files-other-than-index-html/586567#586567</a><br> location /weights {<br> root /home/raphy/www;<br> try_files $uri $uri/ =404;<br> proxy_set_header X-Real-IP $remote_addr;<br> proxy_set_header Host $host;<br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br> # Following is necessary for Websocket support<br> proxy_http_version 1.1;<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection "upgrade";<br> }<br><br>}<br><br>server {<br> if ($host = grasp.deals) {<br> return 301 https://$host$request_uri;<br> } # managed by Certbot<br><br><br> listen 80 default_server;<br> listen [::]:80 default_server;<br> error_page 497 https://$host:$server_port$request_uri;<br> server_name ggc.world;<br> return 301 https://$server_name$request_uri;<br><br> access_log /var/log/nginx/grapdeals-access.log combined;<br><br> add_header Strict-Transport-Security "max-age=31536000";<br> location = /favicon.ico { access_log off; log_not_found off; }<br><br> location / {<br> proxy_pass <a href="http://127.0.0.1:8080">http://127.0.0.1:8080</a>;<br> proxy_http_version 1.1;<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection "upgrade";<br> #proxy_set_header Host $host;<br> }<br>}<br><br># <a href="https://www.nginx.com/blog/nginx-nodejs-websockets-socketio">https://www.nginx.com/blog/nginx-nodejs-websockets-socketio</a>/<br># <a href="https://gist.github.com/uorat/10b15a32f3ffa3f240662b9b0fefe706">https://gist.github.com/uorat/10b15a32f3ffa3f240662b9b0fefe706</a><br># <a href="http://nginx.org/en/docs/stream/ngx_stream_core_module.html">http://nginx.org/en/docs/stream/ngx_stream_core_module.html</a><br><br>upstream websocket {<br> ip_hash;<br> server localhost:3000;<br>}<br><br>server {<br> listen 81;<br> server_name grasp.deals;<br><br> #location / {<br> location ~ ^/(websocket|websocket\/socket-io) {<br> proxy_pass <a href="http://127.0.0.1:4201">http://127.0.0.1:4201</a>;<br> proxy_http_version 1.1;<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection "upgrade";<br> proxy_set_header X-Forwared-For $remote_addr;<br> proxy_set_header Host $host;<br><br> proxy_redirect off;<br> proxy_set_header X-Real-IP $remote_addr;<br> }<br>}<br>#<br><a href="https://stackoverflow.com/questions/40516288/webpack-dev-server-with-nginx-proxy-pass">https://stackoverflow.com/questions/40516288/webpack-dev-server-with-nginx-proxy-pass</a><br><br><br>upstream golang-webserver {<br> ip_hash;<br> server <a href="127.0.0.1:2000">127.0.0.1:2000</a>;<br>}<br><br>server {<br><br> root /puser/add;<br><br> ssl_protocols TLSv1.2 TLSv1.3;<br> ssl_ciphers<br>EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;<br> ssl_prefer_server_ciphers on;<br> ssl_session_cache shared:SSL:50m;<br><br> location / {<br> proxy_pass http://golang-webserver;<br> proxy_http_version 1.1;<br> proxy_set_header Upgrade $http_upgrade;<br> proxy_set_header Connection "upgrade";<br> #proxy_set_header Host $host;<br> }<br>}<br><br><br>What's the problem with this nginx configuration?<br><br>Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,291599,291599#msg-291599">https://forum.nginx.org/read.php?2,291599,291599#msg-291599</a><br><br><hr><br>nginx mailing list<br>nginx@nginx.org<br><a href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a><br><br></pre></body></html>