-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal Server Error Exchange365 #35
Comments
Good Morning @Jan-Gerrit So the error is occurring in this code block, integration_ews/lib/Controller/UserConfigurationController.php Lines 119 to 138 in 7f2eb5b
This code block handles the response/redirect from O365. Once you authenticate with O365 you get redirected to "https://(your domain)/apps/integration_ews/connect-ms365?code=(the O365 access code)" According to your error, the "code" part of the URL is blank, even tough I can see the "code" in the URL from the screen shot you sent. Are you using a proxy of some sort? Or some kind of filter? That would be filtering out the code part. |
Thank you for your quick reply No, there is no proxy installed in front of it.
If I understand correctly, it is because O365 transferred not the required value here. So it is a missconfiguration in O365. Am I right about that? The required authorization is set https://cloud.XXX/apps/integration_ews/connect-ms365?code=0.AXkAIDgda0AZi....... (very long URL) |
No. Looks like the redirect is working properly. BUT, NC is phrasing the "code" argument wrong, before it passes it to the App. In your screen shot, I can see the "code" argument exists (this means O365 sent the value) but when NC runs the "UserConfigurationController::ConnectMS365" function the value of the code arrangement is "NULL" (nothing). So this is either an NC issue or Apache issue... This is correct... Here is mine from a test I just did... So there is something inside your NC setup that is causing this. If you have the ability to see the Apache access logs, you should be able to see a request like this one... "172.22.96.1 - - [14/Feb/2024:08:52:52 -0500] "GET /apps/integration_ews/connect-ms365?code=0.AW8AAhYC7nSSxkmxx5ZxjIV_.......#&session_state=62f70b65-2fab-439b-b5a3-ad90b73d60a1 HTTP/2.0" 200 8972 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0" This will show you what Apache is seeing. You can submit the URL you have in a new browser windows, and watch the apache logs. |
Hi, @ksainc Thanks for the guide! I redid my setup according to your guide and sadly I experienced the exact same problems as @Jan-Gerrit described them above. My Nextcloud log output looks exactly like his so I will not post it again. |
I checked the access.log and it is the same entry as yours. |
Hi @arno1979 and @Jan-Gerrit Okay, so it seems you are both using Apache. I have been testing and using Nginx as a web server using a PHP socket. If Apache is seeing the correct URL being submitted, then the next thing that could be causing the problem is what Apache is passing to PHP. Can you give me a bit of details on how your Apache is connected to PHP? What PHP module are you using? (php-fpm, etc) Are you using PHP via TCP connection (server 127.0.0.1:9000;) or socket (server unix:/var/run/php/php8.2-fpm.sock)? |
Hi @ksainc |
Okay, so if I read this correctly you are using FPM on a socket with a or FCGI? Could you test this with just FPM on a socket. Basically remove the "|fcgi://localhost" part. |
Never mind ignore my this, this will not work. |
Hi @arno1979 and @Jan-Gerrit, Seems this might be your issue. https://stackoverflow.com/questions/7724270/max-size-of-url-parameters-in-get Basically, I think either there is some kind of parameter length limit on Apache or FPM. |
I looked into this and even tried to add the suhosin parameter to my php.ini but it doesn't change anything. I think this simply has to do with the fact that the Suhosin PHP extension is not developed anymore and adding the parameters has no effect as they are simply ignored. The last Suhosin release was in 2015 and there is no version available for PHP 8.x. While researching this I read multiple times that the accepted length of the GET parameter values could also be a browser issue. |
@arno1979 I mean with apache2 the default setting is 8177 characters. I tried to increase it using LimitRequestLine 100000. However, it hasn't changed the problem. In php-fpm my limit is set to 4000 The transfer from O365 definitely works. I tested the whole thing on another server that runs under nginx, where it worked without any problems |
So we are definately faced with an Apache problem, right? |
Good Morning, @Jan-Gerrit thank you for confirming that this is working in Nginx. @arno1979 yes, this seems to be a Apache issue, Apache seems to be removing the "code" value when it is forwarding the request to php-fpm. @Jan-Gerrit and @arno1979 are you using any plugins like mod_security with your Apache installation? Otherwise there must be something in the .htaccess file that is causing this. Sebastian |
Here is the list of my modules in apache2 Loaded Modules: The .htaccess file located in the document root of the nextcloud ist attached. |
Here are the modules loaded with my apache server: Loaded Modules: The .htaccess file comes shipped with nextcloud as far as I know: For completion's sake this is what my apache virtual host file for nextcloud looks like [slightly cleaned up for privacy reasons], the non-standard directives are recommendations taken from the nextcloud documentation:
|
Morning @arno1979 and @Jan-Gerrit Okay, those look like pretty standard configurations. I'm going to install Apache on my test system and see if I can replicate and solve this issue. Sebastian |
Hey @ksainc, I just wanted to ask if you made any progress yet or if I can help in any way? |
Hey @ksainc I am also facing the same error... |
I am also still waiting for progress on this problem. |
@arno1979 My version is NC 28, but it's still not working! |
Yes, we know. If you read up on the problem in this issue you will see that it the problem only occurs if you are running Nextcloud (no matter which version) on Apache. The developer built the plugin on a system running Nginx as webserver and the problem does not occur there. |
I noticed that my URI contained /index.php/apps/ and the return URI from Microsoft did not have /index.php/ included, which was causing a 500 error. I updated my Nextcloud config.php with the below commands and all is working. Add this line to your Nextcloud config.php Run this OCC command to reload. |
After entering the Microsoft 365 Authentication Settings, I try to log in to Exchange 365 via the Connected Accounts tab. The login window opens and I can log in successfully to Exchange 365 . After the Login, the error then appears.
Internal Server Error
The server was unable to complete your request.
If this happens again, please send the technical details below to the server administrator.
More details can be found in the server log.
In the Nextcloud-Log the following error message appears
OCA\EWS\Controller\UserConfigurationController::ConnectMS365(): Argument #1 ($code) must be of type string, null given, called in /var/www/html/cloud.XXX.de/lib/private/AppFramework/Http/Dispatcher.php on line 230 in file '/var/www/html/cloud.XXX.de/apps/integration_ews/lib/Controller/UserConfigurationController.php' line 119
The Microsoft Exchange 365 configuration was created using these instructions:
https://github.com/ksainc/integration_ews/blob/main/docs/o365.md
Debian10
Apache2.4
PHP 8.1.27
Memory limit: 8 GB
Max execution time: 3600
Upload max size: 16 GB
OPcache Revalidate Frequency: 1
Extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, Reflection, SPL, session, standard, sodium, cgi-fcgi, mysqlnd, PDO, xml, apcu, bcmath, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, igbinary, imagick, intl, ldap, exif, mysqli, pdo_mysql, Phar, posix, readline, redis, shmop, SimpleXML, smbclient, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, libsmbclient, Zend OPcache
The text was updated successfully, but these errors were encountered: