๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ๋ฐœ/์„œ๋ฒ„ ํ™˜๊ฒฝ

[nginx] url ์„œ๋ฒ„ ์ด๋ฏธ์ง€ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ :: ๋งˆ์ด์ž๋ชฝ

by ๐ŸŒปโ™š 2018. 10. 18.

ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋‹ค๋ณด๋ฉด ์ด๋ฏธ์ง€์„œ๋ฒ„๋ฅผ ์‚ฌ์šฉํ• ๋•Œ๊ฐ€ ๋งŽ๋‹ค.

ํŒŒ์ผ์„ ์ด๋ฏธ์ง€์„œ๋ฒ„์—์„œ ๋‹ค์šด๋ฐ›์•„์„œ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ๋ณด๋‹ค๋Š” ์ด๋ฏธ์ง€ ์„œ๋ฒ„์— ์žˆ๋Š” ๊ทธ์ž์ฒด๋ฅผ url์„ ํ†ตํ•ด์„œ ๋ถˆ๋Ÿฌ์˜ค๋Š”๊ฒŒ ํšจ์œจ์ ์ด๋‹ค.

์˜ˆ์ œ์˜ ์ด๋ฏธ์ง€์„œ๋ฒ„๋Š” centOs๋ฅผ ์‚ฌ์šฉํ–ˆ๋‹ค.


nginx๋ฅผ ์‚ฌ์šฉํ•ด์„œ configure์— location์„ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ์‰ฝ๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.

nginx ์„ค์น˜(http://myjamong.tistory.com/9)


nginx conf ๋””๋ ‰ํ† ๋ฆฌ์˜ nginx.confํŒŒ์ผ์„ ์—ด์–ด์„œ ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.


nginx.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
 
        ...
        ...
        ...
 
        location /images {
                alias /home/jamong/images;
        }
        
        ...
        ...
        ...
 
    }
 
 

cs



์œ„์˜ ๊ฒฝ๋กœ(/home/jamong/images)์— imageํŒŒ์ผ๋“ค์„ ๋„ฃ์–ด์ค€๋‹ค.

url๋กœ ๋ถˆ๋Ÿฌ์ค„๋•Œ๋Š” /images ๋’ค์— ์ด๋ฏธ์ง€ํŒŒ์ผ ๋ช…์œผ๋กœ ๋ถˆ๋Ÿฌ์ฃผ๋ฉด ๋œ๋‹ค.

๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ด์šฉํ•ด์„œ ํ™•์ธ์„ ํ•ด๋ณธ๋‹ค.


์˜ˆ์‹œ : http://์„œ๋ฒ„id/images/ํŒŒ์ผ๋ช…


nginx๋กœ tomcat์„ ๊ฐ€๋ ค์ค˜์„œ ํฌํŠธ๋Š” ์„ค์ •ํ•˜์ง€ ์•Š์•„๋„ ๋ ๊ฒƒ์ด๋‹ค.

๋Œ“๊ธ€