loentar / ngrest

Fast and easy C++ RESTful WebServices framework
Apache License 2.0
465 stars 94 forks source link

Editing location directive for Nginx #54

Closed hoang408 closed 6 years ago

hoang408 commented 6 years ago

I am following this guide: github.com/loentar/ngrest/wiki/Deploy-ngrest-under-Nginx

At the part edit location directive setting regex to all your bound ngrest service resource paths, how exactly can I do it? The provided example in here is for Apache only (which I don't have), and there is no file or folder with ngrest name under my /etc folder. Could you please help?

loentar commented 6 years ago

yes, it's for Apache, but still about the same things.

Let's say you have some service Calculator which is bound to some resource /calculator. The required location for your service will be

location ~ /calculator {

the second argument /calculator is the joint point for ngrest - nginx will redirect all requests to /calculator to ngrest.

If want to access ngrest service tester with your service, you have to add it's resource, which is located in /ngrest.

location ~ /(calculator|ngrest) {

if you have some additional services like echo, add it:

location ~ /(calculator|ngrest|echo) {

then nginx will redirect all requests to /calculator, /ngrest, /echo to ngrest which will route it to the corresponding service.

Aslo this topic may help:

https://groups.google.com/forum/#!searchin/ngrest/nginx%7Csort:date/ngrest/uMYTZ5OfIGU/UPIuJ2FwAwAJ