2017-04-26 5 views
0

http://www.dummy.com/foo/bar/test의 요청을 http://127.0.0.1/hello/world으로 리디렉션하는 역방향 프록시를 구현하고 싶습니다. 나는 통과하기 전에 재 작성을 추가하는 시도하고 작동하지 않는 것 같다 ...Nginx proxy_pass에서 URL을 다시 작성 하시겠습니까?

server { 
listen 80; 
listen [::]:80; 

server_name www.dummy.com; 

# access_log /var/log/nginx/upstream_log.log 

location/{ 
    root /usr/share/nginx/html/dummy; 
} 

location /foo/bar/test { 
    rewrite ^/foo/bar/test /hello/world break; 
    proxy_pass http://127.0.0.1/; 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $scheme; 

    access_log /var/log/nginx/upstream_log.log upstream_logging; 
} 

}

뭔가가 누락 된 거기 또는 잘못 구성?

+0

작동하지 않는 기능은 무엇입니까? 그 결과는 무엇입니까? 로그 파일에 뭔가가 있습니까? –

+0

우편함과 함께 nginx에 요청하면 http 상태 404가 반환됩니다. URL이 다시 쓰이지 않는 것 같습니다. 나중에 로그를 게시 할 것입니다. 감사 – Rex

답변

0

위의 구성이 예상대로 작동합니다 ... 위의 구성을 테스트 할 때 다른 서버가 잘못 구성되었습니다.