반응형

안녕하세요 가야태자 @talkit 입니다. 

리눅스/Linux Slack 대체 프로그램 Mattermost를 설치해보자. How to install Mattermost on Ubuntu Linux https://talkit.tistory.com/695

위글에 이어서 ^^ 지금 현재 저는 성공 했습니다. 위에 보이시겠지만, ^^

https 모드로 동작하고 있습니다. 

지금 현재 조금 더 공부해야 할 것은 NGINX 프록시로 설정하는 부분입니다. 이부분은 또 성공 하면 글을 쓰도록 하고 제가 성공한 부분이 mattermost를 직접 https로 운영하는 것을 알려 드리겠습니다. 

1. 우선, 도메인을 하나 사셔야 합니다. 

요즘 저는 https://www.hosting.kr 에서 도메인을 구매하고 있습니다. 저렴 합니다. ^^

2. certbot라는 프로그램을 깔아야 합니다. 

무료 SSL 인증서인 Let's Encrypt 스크립트를 이용해서 진행할 계획이어서 certbot을 설치 해야 합니다. 

sudo apt update
sudo apt install certbot python3-certbot-nginx

NGINX는 안까셔도 될 것 같지만, ^^

저는 궁극적으로 nginx위에 https를 올리고 mattermost를 운영하고 싶어서 일단 설치 했습니다. 

3. http로 성공한 mattermost에 접속 하셔서 다음과 같이 설정 합니다. 

System Console에 접속 하셔야 하구요.

ENVIRONMENT > Web Server 항목의 내용은 변경 해야 합니다. 

1) Site URL을 https://구매한도메인:443 으로 변경하시고

2) Listen Address를 :443으로 변경 하십시오.

3) Fordward port 80 to 443 을 true로

4) Connection Security를 TLS로 변경 하십시오.

5) Use Let's Encrypt를 true로 변경하십시오.

일단 이렇게 하시면 끝입니다. 

그리고 맨 아래에 Save 버튼을 클릭 합니다. 

sudo setcap cap_net_bind_service=+ep /opt/mattermost/bin/mattermost

위 명령어를 이용해서 mattermost가 1000번대 이하의 포트에서 실행 되도록 바꾸줍니다. 

저는 이것 때문에 한동한 고생했습니다. 고생하지 마시기를 저도, 매뉴얼을 제대로 안읽는 스타일이라서 ^^

sudo systemctl restart mattermost

mattermost를 재시작 또는 시작 해주시면 됩니다. 

그러면, 설치가 잘 될 것으로 생각 됩니다. 

이게 NGINX하고 충돌이 일어 납니다. 이건 아직 해결을 못했습니다. 

NGINX가 깔려 있지 않는 곳에서 운영 가능 합니다. 

일단 NGINX를 안쓰시면 ^^ 

sudo systemctl stop nginx
sudo systemctl disable nginx

위명령어로 nginx를 끄고, 자동실행이 안되게 하십시오.

Mattermost만 운영할때이고, 다른 사이트와 같이 운영해야하면 일단 저는 http로 사용하시는 것을 권해 드려야겠네요.

NGINX 관련 설정이 성공하면 다시 글을 작성하겠습니다. 

감사합니다. 

 

반응형
반응형

안녕하세요 가야태자 @talkit 입니다. 

NGINX 관련 문서들을 열심히 적고 있습니다. 

오늘은 위 그림에서 보이는 Not secure를 해결하고자 합니다. 

선행과정

리눅스 설치하기

리눅스/Linux VMWARE에 우분투/Ubuntu 20.04 설치하기/Install https://talkit.tistory.com/677

리눅스/Linux VMWARE에 우분투/Ubuntu 18.04 설치하기/Install https://talkit.tistory.com/637

위두 글을 이용해서 VMWARE에 리눅스를 설치 하십시오.

NGINX 설치하기 

리눅스/Linux 우분투에 NGINX Web server 설치하기 How to install NGINX Web server on Ubuntu Linux.  https://talkit.tistory.com/700 

위글을 참고 하시면 됩니다. 

도메인 이름 구매하기

https://www.hosting.kr 

 

글로벌 IT 파트너 - 호스팅케이알(HK)

KISA 고객만족도 최다 선정, 도메인 최저가 제공, 기업/공공도메인, 도메인연결/웹호스팅 무료, 서버, 아마존클라우드(AWS), G Suite, 홈페이지제작 1644-7378

www.hosting.kr

요즘 저기가 도메인이 저렴 한 것 같습니다. 

저는 어제 도메인을 하나 구매 했습니다. ^^

SSL이 IP(아이이) 기반으로 인증이 안되기 때문에 도메인을 구매 하셔야 합니다. 

NGINX 서버블락(Server Block) 설정

리눅스/Linux NGINX 웹서버 설정하기 How to configure NGINX Documents Files.  https://talkit.tistory.com/701

제 글을 계속 읽고 계신다면, 위 글이 서버 블락에 대해서 설명하고 있습니다. 

example.com 대신에 구매하신 도메인 관련 서버블락으로 만드시면 됙, default를 지우셨듯이 example.com 파일을 지우고 새로운 파일을 넣으시면 됩니다. ^^

그러면 이제 실제로 우리가 하고자는 SSL 설정을 시작 해보겠습니다. 

Let's Encrypt를 통한 SSL 설정하기

Certbot를 설치 합니다. 

sudo apt update

습관적으로 계속 한다고 생각 하시면 되구요.

sudo apt install certbot python3-certbot-nginx

서트봇 관련 패키지와 플러그인을 설치 합니다. 

저는 설치가 잘되었습니다. 이번에는 너무 길이서 ^^

server_name example.com www.example.com;

서버네임을 변경하는 과정인데 저는 도메인을 하나 따서 진행 합니다.  example.com 대신에 제 실제 도메인을 넣었습니다. 

여러분들도 실제로 구매하신 도메인을 넣어셔야 합니다. 

혹시 DNS 설정과 관련된 문제는 제가 다른 글에서 한번 써보겠습니다. 

방화벽 설정

이번에도 생략 합니다. ^^

SSL/TLS 인증서 획득하기

sudo certbot --nginx -d example.com -d www.example.com
 sudo certbot --nginx -d example.com -d www.example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Waiting for verification...
Challenge failed for domain example.com
http-01 challenge for example.com
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: example.com
   Type:   connection
   Detail: 공인아이피: Fetching
   http://example.com/.well-known/acme-challenge/f8kAgZFm0jvoMhu3mbtN5F7IS7B7xcXupFP1XN7C-NU:
   Timeout during connect (likely firewall problem)

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

저는 집에 있는 컴픀터에 SSL인증 중이라서 ^^ 오류가 나네요 T.T 제가 보안 때문에  몇가지 검사를 위해서 서버에 접속을 했는데 접속이 안된답니다. ^^

그래서 저는 IP타임 공유기의 설정을 변경해서 다시 아래 명령어를 수행 했습니다. 

 

 sudo systemctl restart nginx
talkit@ubuntu:~$ sudo certbot --nginx -d example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/example.com

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2023-04-01. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

위와 같이 성공 했습니다. 

오 ^^

오 저 앞에 Not secure가 없어졌습니다. ^^

이번 글은 여기까지 하고, 다음글에서는  Let's Encrypt의 갱신 자동화에 대해서 글을 또하나 적어보고, 또한 도메인 구매와 도메인 설정(DNS)에 관해서 알아보겠습니다. 

감사합니다. 

반응형
반응형

안녕하세요 가야태자 @talkit 입니다.

리눅스/Linux 우분투에 NGINX Web server 설치하기 How to install NGINX Web server on Ubuntu Linux. https://talkit.tistory.com/700

앗 지난 번 글이 블로그에 700번째 글이었네요 ^^

요즘 블로깅을 열심히하고 있습니다.

NGINX 설정파일 위치

/etc/nginx/sites-available

우분투의 경우 nginx의 설정파일을 저기 들어 있습니다.

sudo vi /etc/nginx/sites-available/default

기본적으로 default라는 파일이 설치하면 존재 합니다.

그래서 저도 한번 열어 보겠습니다.

# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
}

일단 SSL이라든지 여러가지 설정이 주석으로 정의 되어 있습니다만, 주석부분은 대부분 지워 버리면 실제로 위와 같은 결과만 나옵니다. ^^

default 서버는 80번 포트에서 대기 중이구요. /var/www/html 폴더에 html 파일이 있습니다.

그리고 시작 파일은 index.html, index.htm, index.nginx-debian.html 이 시작 파일 입니다.

default를 없애고, example를 만들어 보도록 하겠습니다. 저는 앞으로 여기서 mattermost를 만들어야겠지요 ^^ 아닌가 mattermost는 나중에 ^^

sudo mkdir /var/www/example

example 디렉토리를 웹 홈에 만들구요.

sudo vi /var/www/example/index.html

index.html 파일을 생성 합니다. 

리눅스/Linux vi/vim NIX에서 가장 유명한 텍스트 편집기 - 글쓰기. One of the best text editor on NIX fields. - Writing https://talkit.tistory.com/699

위 글을 보시면 vi로 글쓰는 방법이 나와 있습니다. ^^ 

<html>
	<body>
	NGINX 테스트 웹페이지에 오신 것을 환영합니다.
	<body>
</html>

위 코드를 index.html에 붙여 넣으십시오. 저장하고 나오시면 됩니다. 

:wq 안 잃어버리셨죠 ^^

sudo vi /etc/nginx/sites-available/example.com

example.com 블락을 만들기위해서 파일을 하나 만들겠습니다. 

server {
listen 80;
root /var/www/example;
index index.html;
server_name 127.0.0.1;
}

위 내용을 붙여 넣으시고, 저장 합니다. 

sudo rm -f /etc/nginx/sites-enabled/default

sites-enabled에서 default 링크를 삭제 합니다. 

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled

음 example.com을 sites-enabled 폴더에 링크를 걸어 줍니다. 

sudo systemctl restart nginx

nginx를 재시작해 줍니다. 

sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-01-01 00:30:21 PST; 10s ago
       Docs: man:nginx(8)
    Process: 3211 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 3212 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 3213 (nginx)
      Tasks: 17 (limit: 19071)
     Memory: 13.6M
     CGroup: /system.slice/nginx.service
             ├─3213 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─3214 nginx: worker process
             ├─3215 nginx: worker process
             ├─3216 nginx: worker process
             ├─3217 nginx: worker process
             ├─3218 nginx: worker process
             ├─3219 nginx: worker process
             ├─3220 nginx: worker process
             ├─3221 nginx: worker process
             ├─3222 nginx: worker process
             ├─3223 nginx: worker process
             ├─3224 nginx: worker process
             ├─3225 nginx: worker process
             ├─3226 nginx: worker process
             ├─3227 nginx: worker process
             ├─3228 nginx: worker process
             └─3229 nginx: worker process

Jan 01 00:30:21 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server...
Jan 01 00:30:21 ubuntu systemd[1]: Started A high performance web server and a reverse proxy server.

재시작 했으면 상태도 한번 확인해주시고 ^^

브라우져에서 확인을 하면

저같은 경우는 위와 같이 나옵니다. ^^

잘 만들어서 잘 구동이 되고 있네요 ^^

오늘은 여기까지 하겠습니다. 제 목표는 저기 Not secure 없애는 거여서  다음글 또는 그 다음 글에서 아마 가능 할 것으로 생각 됩니다. ^^

감사합니다.

 

반응형
반응형

 

이번에 참여해서 진행하고 있는 프로젝트 요구사항 중에 하나가

 

보안서버를 적용 하는 것이었습니다.

 

그런데,

 

몇가지 이슈 때문에 전체에 SSL을 적용하는 것으로 했습니다.

 

몇가지 우여 곡절 끝에

 

Application이 있는 서버와 이미지 서버를 분리 하기로 했습니다.

 

그런데 이미지서버가 주기적으로 매우 느려 지는 현상을 발견 했습니다.

 

그래서 아파치 설정을 변경 하던 중에

 

#SSLSessionCache        none
#SSLSessionCache        shmht:/usr/********/apache2/logs/ssl_scache(512000)
#SSLSessionCache        shmcb:/usr/********/apache2/logs/ssl_scache(512000)
SSLSessionCache         dbm:/usr/********/apache2/logs/ssl_scache
SSLSessionCacheTimeout  300

 

이렇게 설정 되어 있는 것을 발견 했습니다.

 

Timeout도 바꿔 보고

 

KeepAliveTime 등도 바꿔 봤지만

 

소용이 없었는뎅

 

위의 것을 발견 하고는

 

그 주기가 5분이라는 것을 알았습니다. ^^;;

 

SSL 세션 캐쉬를 남기는 시간 5분마다 느려졌던거죠 T.T

 

그래서

 

젤위에 있는 none를 주석을 풀고

 

밑에 있는 두줄

 

시간 설정과 캐쉬 파일 설정을

 

주석 처리 했습니다.

 

그리고 아파치를 다시 켜서

 

스트레스 테스트를 진행 했는데

 

끄떡 없는 것을 발견했습니다.

 

저거 발견하기 전에 삽질한걸 생각하면 T.T

 

다른 분들은 이런 삽질을 좀 안했으면 해서 적어 봅니다.

 

좋은 하루 되십시오.

 


 

이 글은 스프링노트에서 작성되었습니다.

반응형
반응형

일반적으로 ab https://yourdomain.com

 

이렇게 하면 

 

 SSL not compiled in; no https support

 

메시지를 만나게 됩니다.

 

그래서 열심히 뒤졌습니다. ^^;;

 

기본적으로 컴파일 된 ab는 SSL을 지원하지 못한다고 되어있더라구용

 

그럼 어떻게 컴파일 해야 되는지를 조사하게 되었습니다.

 

SSL을 컴파일 할때 기본적으로

 

./configure --with-ssl --with-mpm=prefork --prefix=/home/ase/non/install --with-mods-shared=most ./configure --with-ssl --with-mpm=prefork --prefix=/home/ase/non/install --with-mods-shared=most

 

위와 비슷한 컴파일 옵션을 줄겁니다.

 

이렇게 하면 아파치로  SSL 서비스를 할 수 있지만

 

ab로 ssl 테스트는 진행 할 수 없습니다.

 

./configure --with-ssl --enable-ssl --with-mpm=prefork --prefix=/home/ase/non/install --with-mods-shared=most

 

컴파일 하실때 옵션을 위와 같이 주시면

 

ssl이 테스트 가능한 ab가 컴파일 이 됩니다.

 

여기서 중요한 것은

 

--enable-ssl 을 추가 해주는 것입니다.

 

아파치 configure의 도움말을 보면

 

--enable-ssl            SSL/TLS support (mod_ssl)

 

요렇게 되어 있답니다.

 

이제 다시

 

./ab  https://yourdomain.com

 

해보니깐

 

일반적으로 http에서 내보내는 메시지와 동일한 값을 보여 주네용 ^^;;

 

모두들 좋은 하루 되십시오..

 

 참고로 제가 테스트 해본 아파치 소스는 apache 2.1.13

 

입니다.

 

그리고

 

잘 아시겠지만 혹시나 해서용

 

yourdomain.com 은 그냥 제가 문서적을때 적는겁니다.

 

자기자신의 도메인이나 테스트하려고 하는 적당한 도메인으로 변경 하십시오 ^^;;

 

 앗 출처...

 

제가 참조한 곳은 

 

아래 주소 입니다.

 

http://www.linuxquestions.org/blog/zhjim-147126/2009/8/24/apache2.2-ab-with-ssl-2204/

 

 

이 글은 스프링노트에서 작성되었습니다.

반응형

+ Recent posts