윈도우 서버에 도메인 없이 IP 번호로 Https 설정하는 한 가지 방법
One way to set up secure HTTPS on a Windows server using an IP address without a domain
도메인에 SSL 인증서를 연결해서 Https 로 연결하는 방법은 많지만
IP 주소에 SSL 인증서를 끼워서 연결하는 방법은 어떻게 할 수 있을까?라는 궁금증에 한번 연구를 해보게 되었습니다
While there are numerous methods for establishing an HTTPS connection by associating an SSL certificate with a domain, I became curious about how to achieve this connection by embedding an SSL certificate with an IP address.
결론적으로 연결은 하였지만
대부분의 시스템과 브라우저에서는 보안상 문제가 있다고 취급을 하기 때문에
인트라넷 시스템에서만 활용하시면 좋을것 같습니다.
In conclusion, while the connection has been successfully established,
it is worth noting that, due to security concerns,
most systems and browsers tend to treat this approach with caution and error.
Therefore, it is recommended to utilize this method primarily within intranet systems.
개요
1. SSL 인증서 획득
2. IIS 세팅
3. 참조
1. SSL 인증서 획득
도메인이 없기 때문에 IP 주소에 대한 SSL 인증서를 획득해야 합니다.
SSL를 세팅하기 위해서는
신뢰할 수 있는 SSL 공급자에서 인증서를 구입하거나
Let's Encrypt와 같은 무료 SSL 인증서를 획득해야 합니다
하지만 도메인이 없는 경우
Let's Encrypt와 같은 방법을 사용할 수 없습니다
Since there is no domain, you need to obtain an SSL certificate for the IP address.
To set up SSL:
You can either purchase a certificate from a trusted SSL provider
or obtain a free SSL certificate from services like Let's Encrypt.
However, in the absence of a domain,
you cannot use methods such as Let's Encrypt
참조
따라서
OpenSSL을 사용합니다
아래 링크에서
OpenSSL Windows 설치 프로그램 파일을 다운로드합니다
https://slproweb.com/products/Win32OpenSSL.html
64비트 서버의 경우
Win64 OpenSSL v3.1.4 EXE
혹은 최신버전을
다운로드 및 설치해주시면 됩니다
설치가 완료되면
OPENSSL_CONF 및 Path 환경변수 세팅을 해줍니다
System Variables
OPENSSL_CONF
C:\Program Files\OpenSSL-Win64\bin\openssl.cfg
System Variables
Path
C:\Program Files\OpenSSL-Win64\bin\openssl
그다음 CMD를 열고 설치를 확인합니다
openssl version
OpenSSL을 활용해서
자체인증서를 생성합니다
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -out Certificate.crt
pfx 파일 생성
openssl pkcs12 -export -out PrivateKeyCert.pfx -inkey privkey.pem -in Certificate.crt -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider"
비밀번호를 입력합니다
Therefore,
We use OpenSSL.
Download the OpenSSL Windows installation program file from the link below: https://slproweb.com/products/Win32OpenSSL.html
For 64-bit servers, Win64 OpenSSL v3.1.4 EXE
Or download and install the latest version.
After installation,
Set the OPENSSL_CONF and Path environment variables.
System Variables: OPENSSL_CONF C:\Program Files\OpenSSL-Win64\bin\openssl.cfg
System Variables: Path C:\Program Files\OpenSSL-Win64\bin\openssl
Next, open CMD and verify the installation:
Utilize OpenSSL to generate a self-signed certificate:
Create a pfx file:
Enter the password when prompted.
2. IIS 세팅
먼저 관리자권한으로
URL rewrite 설치
https://www.iis.net/downloads/microsoft/url-rewrite
ARR 설치
https://www.iis.net/downloads/microsoft/application-request-routing
를 해줍니다
다운로드 후에 아래와 같은 명령어로
CMD로 설치가 가능합니다
msiexec /i requestRouter_amd64.msi
서버에서 IIS를 실행한 다음
서버 인증서를 누르고 위에서 생성한 PFX 인증서를 가져옵니다
install
url rewrite and arr
URL 재작성을 누르고
URL redirect를 현재 실행 중인 앱의 포트로
ReverseProxy를 진행해 줍니다
왼쪽에 실행 중인 서버의
콘텍스트 메뉴를 켜고
바인딩 설정도 2개 해줍니다
https 443 + 인증서
http 80
그다음
필요시에 web.config도 수정해 줍니다
Click on URL Rewrite,
perform a URL redirect to the port of the currently running app through ReverseProxy.
On the left, access the context menu of the running server,
and configure two bindings:
https 443 + certificate http 80
Next,
modify the web.config if necessary
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS, PUT, DELETE" />
</customHeaders>
</httpProtocol>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
3. 참조
https://aspdotnet.tistory.com/2653
https://learn.microsoft.com/ko-kr/iis/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module
https://stackoverflow.com/questions/61767431/can-iis-have-https-binding-without-certificate
'DevOps > Window' 카테고리의 다른 글
윈도우 Hyper V 가상 머신 (Ubuntu) 고정 아이피 세팅 (0) | 2024.12.15 |
---|---|
윈도우 부팅 시 자동 실행되는 프로그램 생성하는 한가지 방법: BAT 파일 만들기 (0) | 2023.10.15 |
Window 서버 Nodejs, Cors, Https, IIS 세팅하기 (0) | 2023.09.06 |