Reputation: 63
I'm new to REST API development,
I have 3 small java projects each having some API's in them.
Sample URLs:
https://example.com/project1/rest/class1/api_name1
https://example.com/project1/rest/class2/api_name2
https://example.com/project2/rest/class3/api_name3
https://example.com/project2/rest/class4/api_name4
https://example.com/project3/rest/class5/api_name5
https://example.com/project3/rest/class5/api_name6
Each url is different, I want base url common for each API something like this
https://example.com/something_common/api_name1
https://example.com/something_common/api_name2
https://example.com/something_common/api_name3
https://example.com/something_common/api_name4
https://example.com/something_common/api_name5
https://example.com/something_common/api_name6
my question is, Is it at all possible and if yes then how to do it? Thanks in advance
Upvotes: 0
Views: 120
Reputation: 8828
You can do it:
If you use Apache, check How To Use Apache HTTP Server As Reverse-Proxy Using mod_proxy Extension. In your case, it would look like:
ProxyPass /something_common/api_name1 http://127.0.0.1:8080/project1/rest/class1/api_name1
Or Nginx - check Understanding Nginx HTTP Proxying, Load Balancing, Buffering, and Caching or Virtual Hosts on nginx (CSC309):
location /something_common/api_name1 {
proxy_pass http://localhost:8080/project1/rest/class1/api_name1;
proxy_request_buffering off;
}
Upvotes: 1