๋ฐ์ํ
thumbnail
๋ฐฐ๊ฒฝ : ์ฌ๋ด Streamlit Framework ๋ฅผ ํตํด ๊ตฌํํ ์ฌ์ดํธ๊ฐ Websocket(์น์์ผ) ํต์ ์ ํ๊ณ ์์ด Apache2 ์ Websocket ํต์ ์ ์ํ ์ค์ ์ ์งํํ์์ต๋๋ค.
1. ์น์์ผ ๋ชจ๋ ํ์ฑํ
Apache2 ๋ชจ๋ ํ์ฑํ ๋ช ๋ น์ด์ธ a2enmod ๋ฅผ ํตํด ์น์์ผ ํฐ๋ ๋ชจ๋์ ํ์ฑํ ํ์์ต๋๋ค.
sudo a2enmod proxy_wstunnel
2. ์ํ์น2 ์น์๋ฒ ์ฌ์ดํธ ์ค์ ํ์ผ ์์
apache2 site-enabled์ conf ํ์ผ์ ์์ ํ์์ต๋๋ค
conf ํ์ผ ์ด๊ธฐ
sudo vi /etc/apache2/site-enabled/[filename].conf
conf ํ์ผ ์ต์๋จ์ ๋ชจ๋ ๋ถ๋ฌ์ค๋ ์คํฌ๋ฆฝํธ ์์ฑ
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule rewrite_module modules/mod_rewrite.so
VirtualHost ๋ด์ฉ ์์ฑ
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ProxyVia On
RewriteEngine On
KeepAlive On
ServerAdmin [youradmin]@[yourserver].kr
ServerName [yourdomain]
# ์น์์ผ ์ค์
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://[yourIP:port]/$1 [P,L]
ProxyPass /meta-generator http://[yourIP:port]/meta-generator
ProxyPassReverse /meta-generator http://[yourIP:port]/meta-generator
ProxyPass / http://[yourIP:port]
ProxyPassReverse / http://[yourIP:port]
Header set Access-Control-Allow-Origin "*"
</VirtualHost>
์ ์ฅ ํ ๋ซ๊ธฐ
:wq
[file-name].conf ๋ ๊ธฐ๋ณธ ํต์ ์ ์ํ ์ค์ ํ์ผ ์ด๊ณ , secure ํต์ ์ ํ์ํ ํ์ผ์ธ [file-name]-le-ssl.conf๋ ์๊ธฐ ๋๋ฌธ์ ์ด ํ์ผ๋ ๋์ผํ๊ฒ ์์ ํ์์ต๋๋ค
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so LoadModule rewrite_module modules/mod_rewrite.so . . . <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin [youradmin]@[yourserver].kr ServerName [yourdomain] RewriteEngine on ProxyPreserveHost On ProxyRequests Off #์น์์ผ ์ค์ RewriteCond %{HTTP:Connection} Upgrade [NC] RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteRule /(.*) ws://[yourIP:port]/$1 [P,L] ProxyPass /meta-generator http://[yourIP:port]/meta-generator ProxyPassReverse /meta-generator http:/[yourIP:port]/meta-generator ProxyPass / http://[yourIP:port] ProxyPassReverse / http://[yourIP:port] KeepAlive On Header set Access-Control-Allow-Origin "*" Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /etc/letsencrypt/live/actions-0003/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/actions-0003/privkey.pem </VirtualHost> </IfModule>
Apache2(์ํ์น) ์น์๋ฒ ์ฌ์คํ
sudo systemctl restart apache2.service
3. ์ ์ฉ ํ์ธ
์ฐธ๊ณ
https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
https://binarycube.tistory.com/2
https://stackoverflow.com/questions/38838567/proxy-websocket-wss-to-ws-apache
๋ฐ์ํ
'๊ธฐํ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํฐ์คํ ๋ฆฌ OpenAPI ์๋น์ค ์ข ๋ฃ (1) | 2024.02.17 |
---|---|
NAT (0) | 2022.12.18 |
Svelte ์ค์น, ํ๋ก์ ํธ ์์ฑ (0) | 2022.11.21 |
[Window] powershell ๊พธ๋ฏธ๊ธฐ (2) | 2022.08.31 |
[Window] nvim ์ค์น ๋ฐ config ์ค์ ํด์ ์๋์ฐ๋ฅผ ๋ฆฌ๋ ์ค์ฒ๋ผ ์ฐ๊ธฐ (0) | 2022.08.16 |
๋๊ธ