Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx.conf for a restful api

I'm currently developing a RESTful api as a bridge between my ios/web application and their shared database, and content.

I found my way to implement RESTful api in PHP on this blog.

I started my development on my OVH Apache-based server. Unfortunately, they didn't provide oauth support on web hosting services and there is no way to install it. OVH told me I needed a dedicated server or a VPS server for this.

Now, I'm going to work on dotCloud. It's a great alternative, I think, but their servers (seemingly Amazon EC2's ones), are nginx-based. This would be the first time I've used a nginx server and I need your help for "translating" this .htaccess to a nginx.conf file.

Before asking for your help, I tried to find a nginx.conf file for this but no one worked. When I pushed them to my dotcloud app, the http service of my app crashed and dotcloud cli said :

14:55:44 [www.0] WARNING: The service crashed at startup or is listening to the wrong port. It failed to respond on port "http" (80) within 30 seconds. Please check the application logs.

Thanks for any help in advance :)

like image 749
abidon Avatar asked Jul 28 '12 16:07

abidon


People also ask

Can I use nginx as API gateway?

One advantage of using NGINX as an API gateway is that it can perform that role while simultaneously acting as a reverse proxy, load balancer, and web server for existing HTTP traffic.

Which config file does Nginx use?

By default the file is named nginx. conf and for NGINX Plus is placed in the /etc/nginx directory. (For NGINX Open Source , the location depends on the package system used to install NGINX and the operating system. It is typically one of /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx.)

Where is nginx default conf?

By default, the configuration file is named nginx. conf and placed in the directory /usr/local/nginx/conf , /etc/nginx , or /usr/local/etc/nginx .

How can I see nginx config?

Through a simple command you can verify the status of the Nginx configuration file: $ sudo systemctl config nginx The output will show if the configuration file is correct or, if it is not, it will show the file and the line where the problem is.


1 Answers

Thanks to this htaccess to nginx.conf converter, and some tricks and tests I've made, here is the corresponding nginx.conf file.

I hope it will help people. ;)

EDIT: link to my configuration is dead, but the converter is still available. As long as you have a valid Apache configuration you're good to go.

like image 90
abidon Avatar answered Oct 15 '22 10:10

abidon