Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted January 4, 20169 yr 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>
January 4, 20169 yr 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.
January 4, 20169 yr 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, 20169 yr by Sly_Ripper
January 5, 20169 yr 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" }
January 5, 20169 yr 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".
January 5, 20169 yr 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
January 5, 20169 yr 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.
January 5, 20169 yr 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.
January 5, 20169 yr I'm experiencing the same issue, it won't go past the testing page. Using plesk 12.5 with nginx proxy.
January 5, 20169 yr 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.
January 5, 20169 yr As far I understand its using proxy. However switching to apache won't make it work either. /le sigh
January 5, 20169 yr 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.
January 5, 20169 yr http://snag.gy/4LIHy.jpg Am I missing a module maybe? Edited January 5, 20169 yr by Fabby
January 5, 20169 yr 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.
January 5, 20169 yr 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, 20169 yr by Sly_Ripper
January 5, 20169 yr 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, 20169 yr by Ahmad E.
January 6, 20169 yr Author 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
January 6, 20169 yr 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, 20169 yr by Ahmad E.
January 7, 20169 yr 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, 20169 yr by Brian K.
January 7, 20169 yr 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
January 20, 20169 yr 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; }
January 20, 20169 yr Author 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?
January 20, 20169 yr 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)
September 6, 20213 yr 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 !