DevOps/Window

윈도우 서버에 도메인 없이 IP 번호로 Https 설정하는 한가지 방법

kimc 2023. 11. 9. 20:35
반응형

윈도우 서버에 도메인 없이 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.

 

window os study

개요

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

 

참조

https://community.letsencrypt.org/t/in-2022-is-it-now-possible-to-get-ssl-without-a-domain-and-only-an-ip-address/176749

 

In 2022, is it now possible to get SSL without a domain (and only an IP address)?

Some people have already asked this before and got a "no" response, but since then, this PR to certbot was merged, so it looks like it is possible now. However, Certbot still has this step when doing certbot certonly --standalone, which doesn't have any me

community.letsencrypt.org

 

따라서

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:

shell
openssl version

Utilize OpenSSL to generate a self-signed certificate:

shell
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -out Certificate.crt

Create a pfx file:

shell
openssl pkcs12 -export -out PrivateKeyCert.pfx -inkey privkey.pem -in Certificate.crt -CSP "Microsoft Enhanced RSA and AES Cryptographic Provider"

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

 

Can IIS have https binding without certificate?

I tried to setup automatic Let's Encrypt certification for a domain using this libray It is easy to setup and I hosted it in IIS.After some errors couldn't make it work. Finally I tried running ap...

stackoverflow.com

 

URL 다시 쓰기 모듈에서 맵 다시 쓰기 사용

이 연습에서는 URL 다시 쓰기 모듈에서 맵을 다시 작성하는 개념을 소개하고 다시 쓰기 맵을 사용하는 다시 쓰기 규칙을 만드는 방법을 안내합니다.

learn.microsoft.com

 

Windows 윈도우 10 에 OpenSSL 을 설치하는 방법

OpenSSL은 TLS (Transport Layer Security) 및 SSL (Secure Sockets Layer) 프로토콜을 위한 모든 기능을 갖춘 툴킷 입니다. Apache 스타일 라이센스에 따라 라이센스가 부여됩니다. 이 튜토리얼은 Windows 운영 체제에

aspdotnet.tistory.com

 

 

 

 

 

 

728x90
반응형