nginx Æ÷Æ® Æ÷¿öµù

¸®¿À   
   Á¶È¸ 11495   Ãßõ 0    

안녕하세요.

8888 포트로 돌리고 있는 앱이 하나 있다고 가정하고..

접속 주소를 www.test.com:8888 라고 할때..

( www.test.com:8888 주소로 가면..

바로 www.test.com:8888/login.html 로 이동하도록 되어있습니다.)


여기에 nginx를 설치해서..

www.test.com:8888 이 주소를.. 

www.test.com/test 가 되게 해줄수 있을까요?



혼자 검색을 해서 단순하게.. 아래처럼 설정을 하고..


   server {
        listen       80;
        server_name  *.test.com;

location /test/ {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8888/;

  }


브라우저 주소창에  www.test.com/test 라고 치면..

주소가 아래와 같이 이동되면서.. 

www.test.com/login.html

nginx 의 404 Not Found 에러가 나버리는데..ㅠ.ㅠ


제가 원한 결과는.. 

www.test.com/test/login.html

이렇게 되는거거든요..ㅠ.ㅠ



이게 가능하려면 어떻게 해야 할까요?

ªÀº±Û Àϼö·Ï ½ÅÁßÇϰÔ.
Á¤Èñ¼· 2016-08
proxy_pass ¸¸ °¡Áö°í Å×½ºÆ® Çѹø ÇØº¸½ÃÁö¿ä
°íÁî³Ë 2016-08
http://serverfault.com/questions/598003/nginx-as-a-proxy-for-tomcat-with-subdirectory Âü°íÇϼ¼¿ä
/ Áö¿ì°í rewrite¹® ÀÛ¼ºÇÏ¼Å¾ß ÇÒ µí ÇÕ´Ï´Ù.
location /test {
rewrite ^(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8888/test/;
}


ÀÌ·¸°Ô ÇϽøé

www.test.com:8888/test

·Î Á¢¼Ó ÇßÀ»¶§
127.0.0.1:8888/test ¿¡¼­ ÀÛµ¿ÇÕ´Ï´Ù.
2Â÷ µµ¸ÞÀÎÀ¸·Î °¢°¢ ´Ù¸£°Ô Á¢¼Ó µÇ°Ô ÇÏ°í ½Í´Ù¸é
http{
server {
listen 8888;
server_name test.test.com;
proxy_set_header  X-Real-IP  $remote_addr;
proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

location / {
rewrite ^(.*)$ /$1 break;
proxy_pass  http://127.0.0.1:8888/test/;
}
}

server {
listen 8888;
server_name service.test.com;
proxy_set_header  X-Real-IP  $remote_addr;
proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

location / {
rewrite ^(.*)$ /$1 break;
proxy_pass  http://127.0.0.1:8888/service/;
}
}
}


ÀÌ·±½ÄÀ¸·Î ¼³Á¤ Çϸé
test.test.com À¸·Î Á¢¼Ó Çϸé 127.0.0.1:8888/test ¿¡ Á¢¼ÓÇѰͰú °°ÀÌ ÀÛµ¿
service.test.com À¸·Î Á¢¼ÓÇϸé 127.0.0.1:8888/service ¿¡ Á¢¼ÓÇѰͰú °°ÀÌ ÀÛµ¿ÇÕ´Ï´Ù.


À§¿Í °°Àº ¹æ¹ýÀ¸·Î µµ¸ÞÀÎ Çϳª¸¦ °¡Áö°í ¿©·¯ ¼­¹ö¿¡ ºÐ»êÇØ¼­ ¼­ºñ½º ÇÏ½Ç ¼ö ÀÖ¾î¿ä.


QnA
Á¦¸ñPage 2302/5741
2014-05   5315177   Á¤ÀºÁØ1
2015-12   1831062   ¹é¸Þ°¡
2023-03   3746   µö¸¶Àεå
2019-02   3630   ³ª³Ê¿ì¸®
2021-08   2491   ÀÌÈñÁÖ
2012-09   7400   ±è°Ç¿ì
2021-08   8502   °ø¹é±â
2009-07   7808   ³ª³Ê¿ì¸®
2014-07   6043   ½É¿ìö
2015-10   5000   ¼ÒÁÖÇѺ´
2009-07   8968   ÀÌ´ëÈñ
2016-10   4458   ¿¥ºê¸®¿À
2016-10   8813   À̹®¿µ
2017-11   3966   ³ª¶ó»ç¶û
2015-11   5346   Ãֽÿµ
2020-04   3001   º¥ÀÚ¸®
2009-09   6394   ¿À¼º±â
2023-04   2305   »õÃÑ
2012-11   10377   95GSR
2020-04   4211   nubian
2019-02   2750   inquisitive
2016-11   5788   ÁÖŹé