nginx
nginx ์ค์น
sudo dnf install nginx -y
# centos 7
sudo amazon-linux-extras install nginx1
sudo systemctl start nginx
curl -i http://localhost
sudo chmod 644 /var/log/nginx
sudo chown -R ec2-user:ec2-user /usr/share/nginx/html
echo "<h1>Hello World</h1>" > /usr/share/nginx/html/hello.html
- http://์์ดํผ/
- http://์์ดํผ/hello.html
์๋ ์์
sudo systemctl enable nginx.service
์ค์
cd /etc/nginx/ && vim nginx.conf
๊ธฐ๋ณธ ์ค์ ํ์ผ
- conf.d/ ํด๋์ ๋๋ฉ์ธ๋ณ๋ก ์ค์ ํ์ผ ๋ถ๋ฆฌ ๊ฐ๋ฅ
Reverse Proxy
- "์๋ฒ๋จ์ ๋ค์์ ์น์๋ฒ๋ฅผ ๋๊ณ , ๋งค๋ฒ ์์ฒญ์ด ๋ฐ์ํ ๋๋ง๋ค ์ด๋ค ์๋ฒ์๊ฒ ์ด ์์ฒญ์ ์ฒ๋ฆฌํ๋๋ก ์ง์ํ ์ง ๊ฒฐ์ ํ๋ ์ญํ ์ ์ํํ๋ค."
location / {
sendfile off;
proxy_pass http://127.0.0.1:3000;
proxy_redirect default;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; # for websocket
proxy_set_header Connection "upgrade"; # for websocket
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_max_temp_file_size 0;
}
client ip forward to WAS
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Fowarded-For $remote_addr;
gzip
http {
...
keepalive_timeout 65;
gzip on;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
...
}
max file upload
client_max_body_size 200M;
nginx for ec2-user
user ec2-user;
chown -R ec2-user:ec2-user /usr/share/nginx/html
http to https
server {
# ...
if ($http_x_forwarded_proto = 'http') {
return 307 https://$host$request_uri;
}
http to https without www.
server {
server_name www.okdevtest.net;
rewrite ^(.*) http://okdevtest.net$1 permanent;
}
server {
listen 443 ssl http2;
server_name okdevtest.net;
๊ด๋ จ
์ฐธ๊ณ