๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์„œ๋ฒ„/Linux

Problem binding to port 80: Could not bind to IPv4 or IPv6.

by yunamom 2022. 7. 5.
728x90
300x250

ssl ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ๊ณผ์ •์—์„œ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋‹ค.

 

ํ•ด๊ฒฐ : 80๋ฒˆ ํฌํŠธ๋ฅผ ์ ์œ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ธฐ์กด ์›น ํ”„๋ ˆ์ž„์›Œํฌ๋‚˜ ํ˜น์€ ์„œ๋ฒ„ ํ”„๋กœ๊ทธ๋žจ์„ ์ข…๋ฃŒํ•˜๊ธฐ

ubuntu:~$ sudo lsof -i :80
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   1031     root    6u  IPv4  25900      0t0  TCP *:http (LISTEN)
nginx   1031     root    7u  IPv6  25901      0t0  TCP *:http (LISTEN)
nginx   1032 www-data    6u  IPv4  25900      0t0  TCP *:http (LISTEN)
nginx   1032 www-data    7u  IPv6  25901      0t0  TCP *:http (LISTEN)
ubuntu:~$ kill 1031

or

ubuntu:~$ sudo systemctl stop nginx

 

SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰๋ฐ›๊ธฐ (standalone)

ubuntu:~$ sudo apt-get install certbot
ubuntu:~$ sudo certbot certonly --standalone -d ๋„๋ฉ”์ธ์ฃผ์†Œ
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalon
.
.
.
.
.
.
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/๋„๋ฉ”์ธ์ฃผ์†Œ/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/green27.duckdns.org/privkey.pem
   Your cert will expire on 2022-10-03. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"

# Nginx์— SSL ์—ฐ๊ฒฐ
ubuntu:~$ sudo vi /etc/nginx/sites-availables/default

server {
        listen 80;
        listen [::]:80;
        
        # HTTPS๋ฅผ ์œ„ํ•œ 443 ํฌํŠธ ๊ฐœ๋ฐฉ
        listen 443 ssl;
        listen [::]:443 ssl;

        root /var/www/html;

        server_name ๋„๋ฉ”์ธ์ฃผ์†Œ;
        
        #SSL ์ธ์ฆ์„œ๋ฅผ ๋„ฃ์–ด์ค€๋‹ค.
        ssl_certificate /etc/letsencrypt/live/๋„๋ฉ”์ธ์ฃผ์†Œ/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/๋„๋ฉ”์ธ์ฃผ์†Œ/privkey.pem;

        location / {
                proxy_pass http://localhost:8080;
        }
}
# :wq ์ €์žฅํ›„ ๋ฆฌ๋กœ๋”ฉ

ubuntu:~$ sudo service nginx reload
ubuntu:~$ sudo service nginx restart

 

728x90
300x250

์ฝ”๋“œ