Jump to content

Recommended Posts

Posted

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>

 

Posted

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.

Posted (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 by Sly_Ripper
Posted
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"
}

 

Posted
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".

Posted
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
Posted
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.

Posted
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.

Posted
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.

Posted (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 by Sly_Ripper
Posted (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 by Ahmad E.
Posted (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 by Ahmad E.
Posted (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 by Brian K.
Posted

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

  • 2 weeks later...
Posted
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;
}
Posted
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?

  • 5 years later...
Posted
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 !

  • 1 month later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...