본문 바로가기
개발/ubuntu

nginx openssl

by 적아38 2022. 6. 12.
728x90
apt-get update
apt-get install nginx openssl

mkdir /etc/nginx/certificate
cd /etc/nginx/certificate
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out nginx-certificate.crt -keyout nginx.key

Commen Name - 서버 IP 작성

Generating a RSA private key
............++++
.......................................................++++
writing new private key to 'nginx.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KR
State or Province Name (full name) [Some-State]:Richard Bang
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:123.123.123.123
Email Address []:
vi /etc/nginx/sites-available/default

default 내용

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name _;
        return 301 https://$host$request_uri;
}
server {
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        ssl_certificate /etc/nginx/certificate/nginx-certificate.crt;
        ssl_certificate_key /etc/nginx/certificate/nginx.key;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
                try_files $uri $uri/ =404;
        }
}
service nginx restart
728x90

'개발 > ubuntu' 카테고리의 다른 글

tmp ci_session 삭제  (0) 2022.07.29
nginx 홈디렉토리 변경  (0) 2022.01.01
[ubuntu] composer 설치  (0) 2021.11.05
[Nginx] Nginx 리다이렉션  (0) 2021.10.28
[ubuntu] SSL 갱신  (0) 2021.08.13

댓글