Nginx 중 proxy질문
10530 단어 nginx
proxy_pass http://localhost:8080 이런 방식 을 URI 가 없 는 방식 이 라 고 한다.다른 하 나 는 포트 번호 뒤에 다른 경로 가 있 는데 하나의 /, 예 를 들 어 proxy_pass http://localhost:8080/ 와 다른 경 로 를 포함한다. 예 를 들 어 proxy_pass http://localhost:8080/abc.즉,
proxy_pass http://localhost:8080 와 proxy_pass http://localhost:8080/ (끝 이 많은 / 는 서로 다른 처리 방식 이 고 proxy_pass http://localhost:8080/ 와 proxy_pass http://localhost:8080/abc 는 같은 처리 방식 이다.URI 가 없 는 방식 에 대해 nginx 는 location 의 경로 부분 을 유지 합 니 다. 예 를 들 어:
location /api1/ {
proxy_pass http://localhost:8080;
}
방문
http://localhost/api1/xxx 시 대리 http://localhost:8080/api1/xxxURI 방식 에 대해 nginx 는 alias 와 같은 교체 방식 으로 URL 을 교체 할 것 입 니 다. 또한 이러한 교 체 는 글자 의 교체 일 뿐 입 니 다. 예 를 들 어:location /api2/ {
proxy_pass http://localhost:8080/;
}
방문
http://localhost/api2/xxx 했 을 때 http://localhost/api2/ (마지막 주의 / 는 http://localhost:8080/ 로 바 뀌 었 고 나머지 xxx 를 더 해 http://localhost:8080/xxx 로 바 뀌 었 다.또 예 를 들 면:
location /api5/ {
proxy_pass http://localhost:8080/haha;
}
방문
http://localhost/api5/xxx 할 때 http://localhost/api5/ 가 교체 http://localhost:8080/haha 되 었 습 니 다. 여기 haha 뒤에 없 음 / 을 주의 하 세 요. 그리고 나머지 xxx, 즉 http://localhost:8080/haha + xxx = http://localhost:8080/hahaxxx, 이상 하 죠?요약:
server {
listen 80;
server_name localhost;
location /api1/ {
proxy_pass http://localhost:8080;
}
# http://localhost/api1/xxx -> http://localhost:8080/api1/xxx
location /api2/ {
proxy_pass http://localhost:8080/;
}
# http://localhost/api2/xxx -> http://localhost:8080/xxx
location /api3 {
proxy_pass http://localhost:8080;
}
# http://localhost/api3/xxx -> http://localhost:8080/api3/xxx
location /api4 {
proxy_pass http://localhost:8080/;
}
# http://localhost/api4/xxx -> http://localhost:8080//xxx, , 。
location /api5/ {
proxy_pass http://localhost:8080/haha;
}
# http://localhost/api5/xxx -> http://localhost:8080/hahaxxx, haha xxx , 。
location /api6/ {
proxy_pass http://localhost:8080/haha/;
}
# http://localhost/api6/xxx -> http://localhost:8080/haha/xxx
location /api7 {
proxy_pass http://localhost:8080/haha;
}
# http://localhost/api7/xxx -> http://localhost:8080/haha/xxx
location /api8 {
proxy_pass http://localhost:8080/haha/;
}
# http://localhost/api8/xxx -> http://localhost:8080/haha//xxx, 。
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간단! Certbot을 사용하여 웹 사이트를 SSL(HTTPS)화하는 방법초보자가 인프라 주위를 정돈하는 것은 매우 어렵습니다. 이번은 사이트를 간단하게 SSL화(HTTP에서 HTTPS통신)로 변경하는 방법을 소개합니다! 이번에는 소프트웨어 시스템 Nginx CentOS7 의 환경에서 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.