ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๊ฐœ์š”

nginx ์„ค์ • ์ค‘์— ์„ค์ •ํ•œ directory๋ฅผ ์ฐพ์ง€ ๋ชปํ•˜๋Š” ๊ฒƒ์œผ๋กœ ํŒ๋‹จ๋˜์–ด log๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ 403 (13: Permission denied) ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๊ณ , ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.

error ๋ฐœ์ƒ ์ƒํ™ฉ

server {
        listen 80;

        root /xxx/xxx/build;
        index index.html;

        server_name _;

        location / {
                try_files $uri $uri/ /index.html;
        }
}

/etc/nginx/sites-available/default์— ์œ„์™€ ๊ฐ™์ด ์„ค์ •์„ ํ•ด๋‘๊ณ  ํ•ด๋‹น ํฌํŠธ๋กœ ์ ‘์†ํ•ด๋ณด๋‹ˆ 500 Error์™€ ํ•จ๊ป˜ ํŽ˜์ด์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์—ˆ๋‹ค.

๊ทธ๋ž˜์„œ ๋ฐ”๋กœ log๋ฅผ ํ™•์ธํ•ด๋ณด์•˜๊ณ , /var/log/nginx/error.log์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

"/xxx/xxx/build/index.html" failed (13: Permission denied)

log๋ฅผ ๋ณด์•„์„œ๋Š” ํ•ด๋‹น ๊ฒฝ๋กœ์— ๊ถŒํ•œ์ด ์—†์–ด ์ ‘๊ทผํ•˜์ง€ ๋ชป ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ํŒ๋‹จํ–ˆ๊ณ , ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•ด๊ฒฐํ–ˆ๋‹ค.

ํ•ด๊ฒฐ ํ•˜๊ธฐ

ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  • nginx์—์„œ root๋กœ ์„ค์ •ํ•œ ๋””๋ ‰ํ† ๋ฆฌ ๊ฒฝ๋กœ์˜ ๊ถŒํ•œ(์œ ์ € ๊ทธ๋ฃน)์„ ํ™•์ธํ•œ๋‹ค.
  • ํ•ด๋‹น ์œ ์ € ๊ทธ๋ฃน์„ /etc/nginx/nginx.conf ์—์„œ ์ผ์น˜์‹œํ‚จ๋‹ค.

ํ•„์ž์˜ ๊ฒฝ์šฐ์—๋Š” ํ•ด๋‹น ๊ฒฝ๋กœ ๊ถŒํ•œ ์œ ์ € ๊ทธ๋ฃน์ด root๋กœ ๋˜์–ด ์žˆ์—ˆ๊ณ 
vi /etc/nginx/nginx.conf ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด vi ํŽธ์ง‘๊ธฐ๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด user๋ฅผ ๋ณ€๊ฒฝํ•ด์ฃผ๋Š” ๊ฒƒ์œผ๋กœ ํ•ด๊ฒฐํ•˜์˜€๋‹ค.

/etc/nginx/nginx.conf

#user www-data;
user root;

reference

๋ฐ˜์‘ํ˜•