Say we have url http://example.com/blog/posts
and we want to use Nginx to serve as a forward proxy, directing that request to a backend that will only see that url as http://example.com/my-blog/foo/posts
.
How is this possible with nginx, no redirects and totally transparent to the backend?
We have the following so far:
rewrite ^/blog/(.*)$ /my-blog/foo$ last;
Currently our logs show the following:
*1 "^(.*)$" matches "/blog/posts"
*1 rewritten data: "/my-blog/foo/posts"
GET /blog/posts HTTP/1.1" 404
Here's an example of what should work for you
location = /blog/posts {
return 301 /my-blog/foo/posts;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.