NGINX๋ ์ต์ ์น ์๊ตฌ๋ฅผ ์ถฉ์กฑํ๋๋ก ์ค๊ณ๋ ์น ์๋ฒ ํ๋ซํผ ์ด๋ค.
์ด ์น ์ฌ์ดํธ๋ ์ฑ์ฅํ๋ ์น์ ์๊ตฌ์ฌํญ์ธ '1๋ง ๊ฐ์ ์ฐ๊ฒฐ'์ ์ ๊ณตํด์ผํ๋ ๋ฌธ์ ์ ๋ํ ํด๋ต์ผ๋ก ์ค๊ณ๋์๋ค . ๋ฐ๋ผ์ ์ด ๊ธฐ์ ์ ํจ์จ์ ์ธ ๋ฐฉ์์ผ๋ก ๋ง์ ์์ ์ฌ์ฉ์์๊ฒ ๋์์ ์๋น์ค๋ฅผ ์ ๊ณตํ๋๋ฐ ์ค์ ์ ๋๊ณ ์๋ค. NGINX๋ 2004 ๋ ์ ์ผ๋ฐ์ธ์๊ฒ ๊ณต๊ฐ๋์์ผ๋ฉฐ ๊พธ์คํ ์ธ๊ธฐ๋ฅผ ์ป๊ณ ์๋ค.
apache์ ๋ฌ๋ฆฌ NGINX๋ ์ค๋๋ ์น์ ์๊ตฌ๋ฅผ ์ฒ๋ฆฌํ๋๋ก ์ค๊ณ๋์๋ค. ํจ์จ์ฑ์ ์ค์ ์ ๋๊ณ ์์ผ๋ฉฐ ๊ฒฝ๋ ์ํคํ ์ฒ์ ๋์ ๋์์ฑ์ด ์๋ค.
[์ฐธ๊ณ ] sites.conf : NGINX์ ์ํด ์๋น์ค๋๋ ๊ฐ์ ํธ์คํธ ์น์ฌ์ดํธ ํ๊ฒฝ ์ค์ . ๋๋ฉ์ธ๋ง๋ค ํ์ผ์ ๋ถ๋ฆฌํด์ ๋ง๋ค ๊ฒ์ ๊ถ์ฅ
์ถ์ฒ - https://prohannah.tistory.com/136[Hello, Hannah!]
Homebrew: 3.4.11
nginx version: nginx/1.21.6
macOS
$ brew install nginx
$ nginx
$ nginx -s <SIGNAL>
quit
ย โ Shut down gracefully (theย SIGQUIT
ย signal)reload
ย โ Reload the configuration file (theย SIGHUP
ย signal)reopen
ย โ Reopen log files (theย SIGUSR1
ย signal)stop
ย โ Shut down immediately (or fast shutdown, theย SIGTERM
ย singal)nginx.conf ์์น
brew๋ฅผ ์ด์ฉํด์ ์ค์นํ ๊ฒฝ์ฐ ์ค์ ์ ์ํ nginx.conf ํ์ผ์ /opt/homebrew/etc/nginx์ ์์ฑ๋๋ค.
$ nano /opt/homebrew/etc/nginx/nginx.conf
server {
listen 80; # IPv4 ํฌํธ๋ฅผ ์ง์ ํ๋ค
listen [::]:80; # IPv6 ํฌํธ๋ฅผ ์ง์ ํ๋ค
server_name ๋๋ฉ์ธ; # ๋๋ฉ์ธ ์ง์ ํ๋ค. "_"๊ฐ ์ฌ์ฉ์ localhost
root /var/www/์์น; # ๊ธฐ๋ณธ ์์ฒญ์ ๋ํด ๋ฐํํ ํ์ผ์ ๊ฒฝ๋ก๋ฅผ ์ง์ ํ๋ค
index index.html; # ์ ๊ฒฝ๋ก์์ ์ฌ์ฉ๋๋ ํ์ผ์ ์ง์
# location์ ํตํด ๋ฉ์ธ ๋๋ฉ์ธ์์ ๋ถ๊ธฐ์ ์ ๋ง๋ค ์ ์๋ค.
location / {
try_files $uri $uri/ =404;
}
}
https://localhost
์ด ์ด์ ํด๋นํฉ๋๋ค.)https://localhost/location
์ด location ๋ผ์ฐํ
์ ํด๋นํฉ๋๋ค.)return 301 https://google.com
ย ์ ํ์์ผ๋ก ์์ฑํ๋ค๋ฉด, googlo.com์ผ๋ก ๋ฆฌ๋ค์ด๋ ํธ ๋๋ค.