OctoDev Posted January 4, 2016 Posted January 4, 2016 Anyone got the rewrite rule for nginx? For apache etc: <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteBase /api/ RewriteRule .* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] </IfModule> Ioannis D and MGB 2
Ioannis D Posted January 4, 2016 Posted January 4, 2016 That was my first question in my mind after the upgrade. It's a good idea an information message in ACP with NGiNX rewrite rules when .htaccess Apache's needs update.
Sly_Ripper Posted January 4, 2016 Posted January 4, 2016 (edited) I just added: location /forums/api { try_files $uri $uri/ /forums/api/index.php; } Now it just seems the API is broken, the key is correctly passed to the script (even checked by echoing the $rawApiKey variable), it just throws an exception: curl http://localhost/forums/api/core/hello --user test: { "errorCode": "3S290\/7", "errorMessage": "INVALID_API_KEY" } curl http://localhost/forums/api/core/hello { "errorCode": "2S290\/6", "errorMessage": "NO_API_KEY" } Edited January 4, 2016 by Sly_Ripper
prupdated Posted January 5, 2016 Posted January 5, 2016 location /api/ { rewrite ^/api/(.*)$ /api/index.php; } Seems to be working (adjust for your directory structure as needed). I used the sample script here: Which outputs as expected (replaced name and url): php testapi.php { "communityName": "name", "communityUrl": "url", "ipsVersion": "4.1.6" } emilhem and Brian K. 2
Sly_Ripper Posted January 5, 2016 Posted January 5, 2016 7 hours ago, prupdated said: location /api/ { rewrite ^/api/(.*)$ /api/index.php; } Seems to be working (adjust for your directory structure as needed). I used the sample script here: Which outputs as expected (replaced name and url): php testapi.php { "communityName": "name", "communityUrl": "url", "ipsVersion": "4.1.6" } Strange, I'm still getting "INVALID_API_KEY".
Ahmad E. Posted January 5, 2016 Posted January 5, 2016 15 hours ago, Sly_Ripper said: I just added: location /forums/api { try_files $uri $uri/ /forums/api/index.php; } Now it just seems the API is broken, the key is correctly passed to the script (even checked by echoing the $rawApiKey variable), it just throws an exception: curl http://localhost/forums/api/core/hello --user test: { "errorCode": "3S290\/7", "errorMessage": "INVALID_API_KEY" } curl http://localhost/forums/api/core/hello { "errorCode": "2S290\/6", "errorMessage": "NO_API_KEY" } I have the same nginx rule and it is working fine for me. You need to use curl --user APIKEY http://domain.com/api/core/hello
Sly_Ripper Posted January 5, 2016 Posted January 5, 2016 1 minute ago, Ahmad E. said: I have the same nginx rule and it is working fine for me. You need to use curl --user APIKEY http://domain.com/api/core/hello Still the same result, I don't have any proper API Keys yet since the admin panel doesn't let you add any until it works with the "test" key.
Ahmad E. Posted January 5, 2016 Posted January 5, 2016 Just now, Sly_Ripper said: Still the same result, I don't have any proper API Keys yet since the admin panel doesn't let you add any until it works with the "test" key. After adding the nginx rule and restarting nginx, just reload the REST API page in the ACP, it should go through automatically and let you add an key.
Get-Gaming Posted January 5, 2016 Posted January 5, 2016 I'm experiencing the same issue, it won't go past the testing page. Using plesk 12.5 with nginx proxy.
Ahmad E. Posted January 5, 2016 Posted January 5, 2016 1 minute ago, Fabby said: I'm experiencing the same issue, it won't go past the testing page. Using plesk 12.5 with nginx proxy. Are you using nginx only or are you using nginx as a proxy for apache? Never used plesk myself so not sure.
Get-Gaming Posted January 5, 2016 Posted January 5, 2016 As far I understand its using proxy. However switching to apache won't make it work either. /le sigh
Ahmad E. Posted January 5, 2016 Posted January 5, 2016 Just now, Fabby said: As far I understand its using proxy. However switching to apache won't make it work either. /le sigh If it's proxy then you don't need nginx rules, you'd need to use the htaccess file that you can download.
Get-Gaming Posted January 5, 2016 Posted January 5, 2016 (edited) http://snag.gy/4LIHy.jpg Am I missing a module maybe? Edited January 5, 2016 by Fabby
Ahmad E. Posted January 5, 2016 Posted January 5, 2016 3 minutes ago, Fabby said: http://snag.gy/4LIHy.jpg Am I missing a module maybe? Doesn't seem like it, you'd need mod_rewrite for the htaccess rule which is enabled.
Sly_Ripper Posted January 5, 2016 Posted January 5, 2016 (edited) 4 hours ago, Ahmad E. said: Are you using nginx only or are you using nginx as a proxy for apache? Never used plesk myself so not sure. Nginx and php-fpm, tested it in Apache and it worked. Edit: I created an API key while using Apache, switched over to Nginx and using that key gives a valid result, but still using "test" as the key fails (and so the AdminCP shows no options to add/edit keys yet). >curl http://localhost/forums/api/core/hello --user a33cb937a4953c72bc4da6e89da39e51: { "communityName": "IPS Community Suite", "communityUrl": "http:\/\/localhost\/forums\/", "ipsVersion": "4.1.6" } >curl http://localhost/forums/api/core/hello --user test: { "errorCode": "3S290\/7", "errorMessage": "INVALID_API_KEY" } @bfarber Should I submit a bug report? Edited January 5, 2016 by Sly_Ripper
Ahmad E. Posted January 5, 2016 Posted January 5, 2016 (edited) 19 minutes ago, Sly_Ripper said: Nginx and php-fpm, tested it in Apache and it worked. Edit: I created an API key while using Apache, switched over to Nginx and using that key gives a valid result, but still using "test" as the key fails (and so the AdminCP shows no options to add/edit keys yet). Should I submit a bug report? Not sure if it's a bug as it worked fine for me on my nginx install, I'll test it on my other site which also runs nginx. Update: Works fine as-well. Edited January 5, 2016 by Ahmad E.
OctoDev Posted January 6, 2016 Author Posted January 6, 2016 Hmm i think it's weird how they are not providing any support or guides regarding nginx.. apache is way too slow, nginx should be one of the default configs supported prupdated, Ioannis D and Brian K. 3
Ahmad E. Posted January 6, 2016 Posted January 6, 2016 (edited) 42 minutes ago, Jimmy Gavekort said: Hmm i think it's weird how they are not providing any support or guides regarding nginx.. apache is way too slow, nginx should be one of the default configs supported Post it in the feedback section. Most developers don't support nginx, unfortunately. But I never had a problem getting things to work myself with nginx. Edited January 6, 2016 by Ahmad E.
Brian K. Posted January 7, 2016 Posted January 7, 2016 (edited) Yeah I'm surprised they haven't added NGINX support. I bet a large chunk of their customers use NGINX yet they're still stuck on Apache for some odd reason. @Ahmad E. the issue really isn't getting things to work with NGINX as anyone that is semi-competent can make it happen. The problem is when you open a support ticket with Invision Power and they use the fact that you have NGINX as a reason not to provide you with proper support. I had issues before where the imageproxy key needed a new hash because I changed my subdomain URL around and when I opened a ticket (this is before I knew about the hashgenerator.php), they shot me down because they claimed they don't support PHP 7 or NGINX. Yet my issue had nothing to do with either of those and I was left to figure it out on my own. Edited January 7, 2016 by Brian K.
JEFF MACK Posted January 7, 2016 Posted January 7, 2016 So not sure what I am doing wrong. I downloaded the file, etc but yet this doesn't seem to work... The API endpoint is not giving the expected response. Check you followed the instructions correctly. The URL being tested is: /api/core/hello
emilhem Posted January 20, 2016 Posted January 20, 2016 On 2016-01-07 at 10:11 PM, JEFF MACK said: So not sure what I am doing wrong. I downloaded the file, etc but yet this doesn't seem to work... The API endpoint is not giving the expected response. Check you followed the instructions correctly. The URL being tested is: /api/core/hello You don't need the file when using NGINX. I'm experiencing the same problem when on my test install. On my production server it works as expected and I'm pretty much using the same config except that the test install uses a auth_basic on the whole site... (this could be the issue!) The following is the path that IPS is trying to access according to the NGINX logs. The post here says that it is invalid https://community.invisionpower.com/4guides/developing-plugins-and-applications/rest-api/sending-your-first-request-r167/ /api/index.php?/core/hello The config I use is the one that @prupdated mentioned above, IE location /api/ { rewrite ^/api/(.*)$ /api/index.php; }
OctoDev Posted January 20, 2016 Author Posted January 20, 2016 10 minutes ago, emilhem said: You don't need the file when using NGINX. I'm experiencing the same problem when on my test install. On my production server it works as expected and I'm pretty much using the same config except that the test install uses a auth_basic on the whole site... (this could be the issue!) The following is the path that IPS is trying to access according to the NGINX logs. The post here says that it is invalid https://community.invisionpower.com/4guides/developing-plugins-and-applications/rest-api/sending-your-first-request-r167/ /api/index.php?/core/hello The config I use is the one that @prupdated mentioned above, IE location /api/ { rewrite ^/api/(.*)$ /api/index.php; } And that works?
emilhem Posted January 20, 2016 Posted January 20, 2016 1 hour ago, Jimmy Gavekort said: And that works? It works on the production server that doesn't use auth_basic (http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic)
FernandoMTA Posted September 6, 2021 Posted September 6, 2021 On 1/20/2016 at 12:36 PM, emilhem said: You don't need the file when using NGINX. I'm experiencing the same problem when on my test install. On my production server it works as expected and I'm pretty much using the same config except that the test install uses a auth_basic on the whole site... (this could be the issue!) The following is the path that IPS is trying to access according to the NGINX logs. The post here says that it is invalid https://community.invisionpower.com/4guides/developing-plugins-and-applications/rest-api/sending-your-first-request-r167/ /api/index.php?/core/hello The config I use is the one that @prupdated mentioned above, IE location /api/ { rewrite ^/api/(.*)$ /api/index.php; } For me I had to do: location ~/api/ { rewrite ^/api/(.*)$ /api/index.php; } Thank you for the solution !
IveLeft... Posted October 25, 2021 Posted October 25, 2021 https://www.nginx.com/blog/converting-apache-to-nginx-rewrite-rules/
Recommended Posts