nginx.conf for a restful api
Asked Answered
T

1

8

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 :)

Talyah answered 28/7, 2012 at 16:16 Comment(4)
If I understand correctly, this .htaccess snippet will send all requests to non-existing files or directories to api.php, appending the original URI in the query string; whereas requests to existing files and directories will also be sent to api.php, but without appending the original URI in the query. Is that really what you need?Chariness
Yes it was that but I found by myself how to do this with nginx.Talyah
Can you share how you did this?Lodge
@freshfunk: look down. there's a link to a htaccess to nginx.conf converterTalyah
T
7

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.

Talyah answered 30/7, 2012 at 15:14 Comment(2)
The nginx.conf is no longer accessible. Could you paste it in your answer?Potent
Sorry @AndrewEisenberg I don't have it anymore. But the converter still works so if you have a working Apache configuration you're good to go :)Talyah

© 2022 - 2024 — McMap. All rights reserved.