Skip to content
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

Mind sharing your nginx conf ? #1

Closed
RomanJos opened this issue Aug 28, 2019 · 15 comments
Closed

Mind sharing your nginx conf ? #1

RomanJos opened this issue Aug 28, 2019 · 15 comments

Comments

@RomanJos
Copy link

Hi I can't make it work nginx return a 405 error and if I add this
error_page 405 =200 $uri;
I took it from here
It simply send as a static file obviously and the hauk app show me the content of the create.php file

@RomanJos
Copy link
Author

RomanJos commented Aug 28, 2019

Well it looks like i'm dumb I forgot to add this
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
in my nginx conf but now the app crash when I hit Start sharing

@bilde2910
Copy link
Owner

Hi - that is correct, you need a PHP backend for this to work. The example you included will work fine for that purpose. Note that you also need to install memcached on your server and enable it in php.ini (both of the memcache and memcached extensions work with Hauk) if you haven't already.

@RomanJos
Copy link
Author

RomanJos commented Aug 28, 2019

I successfully installed memcached.so and added it in php.ini by following this post and I get
PWD => /home/roman/php-memcached $_SERVER['PWD'] => /home/roman/php-memcached
by executing php7.3 -i | grep memcached so I guess its loaded(?)
But the app still crash
my adb log :
08-28 21:21:32.410 17429 17452 W System : in loadDexFile: /system/framework/tcmclient.jar 08-28 21:21:32.411 17429 17452 W System : tcmclient load failed: java.lang.NoSuchMethodException: registerTcmMonitor [interface com.quicinc.tcmiface.DpmTcmIface] 08-28 21:21:32.416 17429 17452 D Linux : [Posix_connect Debug]Process info.varden.hauk :443 ip--**My hauk server** 08-28 21:21:32.587 17429 17429 D AndroidRuntime: Shutting down VM 08-28 21:21:32.587 17429 17429 E AndroidRuntime: FATAL EXCEPTION: main 08-28 21:21:32.587 17429 17429 E AndroidRuntime: Process: info.varden.hauk, PID: 17429 08-28 21:21:32.587 17429 17429 E AndroidRuntime: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at c.a.a.g.a(:3) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at c.a.a.f.onPostExecute(:1) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:695) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:180) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at android.os.Looper.loop(Looper.java:217) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7387) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:500) 08-28 21:21:32.587 17429 17429 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:865) 08-28 21:21:32.588 17429 17429 W System.err: Application uncaught exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 08-28 21:21:32.588 17429 17429 W System.err: at c.a.a.g.a(:3) 08-28 21:21:32.588 17429 17429 W System.err: at c.a.a.f.onPostExecute(:1) 08-28 21:21:32.588 17429 17429 W System.err: at android.os.AsyncTask.finish(AsyncTask.java:695) 08-28 21:21:32.588 17429 17429 W System.err: at android.os.AsyncTask.access$600(AsyncTask.java:180) 08-28 21:21:32.588 17429 17429 W System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712) 08-28 21:21:32.588 17429 17429 W System.err: at android.os.Handler.dispatchMessage(Handler.java:106) 08-28 21:21:32.588 17429 17429 W System.err: at android.os.Looper.loop(Looper.java:217) 08-28 21:21:32.588 17429 17429 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7387) 08-28 21:21:32.588 17429 17429 W System.err: at java.lang.reflect.Method.invoke(Native Method) 08-28 21:21:32.588 17429 17429 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:500) 08-28 21:21:32.588 17429 17429 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:865) 08-28 21:21:32.590 1507 10429 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1009 com.android.server.am.ActivityManagerService.feedbackIssue:16781 com.android.server.am.ActivityManagerService.feedbackCrash:16794 com.android.server.am.ActivityManagerService.handleApplicationCrashInner:16749 com.android.server.am.ActivityManagerService.handleApplicationCrash:16691 08-28 21:21:32.590 1507 10429 W ActivityManager: Force finishing activity info.varden.hauk/.MainActivity

@bilde2910
Copy link
Owner

bilde2910 commented Aug 28, 2019

This looks like a server misconfiguration. Can you try with the demo server? Connect the app to https://apps.varden.info/demo/hauk/ with password demo. Note that the demo server is limited to max 2 minutes share duration.

If you run a Debian flavor (Debian, Ubuntu, etc.) on your server, you can install memcached with:

sudo apt install memcached php-memcached

... then adding extension=memcached to the php.ini file, and restarting php-fpm. Check your server's error logs/PHP output as well to see if something might be logged there, it could give a clue to what is wrong.

php -i | grep memcache should return memcached support => enabled, and php -m should list one of the memcache extensions.

@RomanJos
Copy link
Author

Oh yeah your server works well I only have GPS issue on my phone so I can't see me on the maps but the app didn't crash.
I forgot to install php-memcached in fact I installed it but I tried to locate memcached.so and nothing appeared so I uninstalled it.
I have memcached support => enabled and memcached.compression etc etc as well so I guess memcached is good. php -m list memcached too but the app still crash lol when doing htpasswd -nBC 10 "" | tail -c +2 do I need to put something inside "" ? because i only past it in my terminal and copy the $2y... string inside the pasword_hash option. I don't have any other idea why its doing that

@bilde2910
Copy link
Owner

It's pretty strange that the app crashes; I can see where in the app source code it happens, but the error itself doesn't make much sense. Since it works on the demo server, though, it's definitely on your server. A few things you can try:

  • Check the error logs from php-fpm to see if you can identify which error is the cause
  • Check nginx's error logs as well
  • Make a new file info.php with the contents <?php phpinfo(); ?> and put it in your web server, then open that file in your browser to double check that memcached is loaded in the PHP module that nginx uses (look for a memcached section like in the screenshot). Make sure you delete the file afterwards, since it could leak information about your server if left there

image

Are you running Debian/Ubuntu or something else? If you can't solve it, I'll set up a VM tomorrow and try setting up nginx + php-fpm from scratch and see if I can reproduce the issue on a fresh install.

@bilde2910
Copy link
Owner

I forgot to add that no, there shouldn't be anything between the quotes when generating the password hash. The exact command to generate the hash is the one you used; it will prompt you for a password in the terminal and then produce a hash $2y..., so you are doing it correctly. You can see how the default hash is set in the default config file here; just replace the hash between the quotes with what the terminal outputs to set the correct password hash for your server instance.

@RomanJos
Copy link
Author

RomanJos commented Aug 28, 2019

Well I followed this post and modified just

1: edit:
sudo vim /usr/local/etc/php-fpm.d/www.conf

by /etc/php/7.3/fpm/pool.d/www.conf and edited at the end, I touch /var/log/fpm-php.www.log && chmod 777 /var/log/fpm-php.www.logand I then reloaded php7.3-fpm with service but the file never get written i also tried to chown www-data.www-data /var/log/fpm-php.www.log and restart but it didn't helped I have nothing new in my nginx error logs I just have in the access log the normal 200 status code on the post /api/create.php and nothing else i created a info.php and ran it with php -S 0.0.0.0:4000 and i have the same version as you but yes everywhere (igbinary json and msgpack support) I think fpm is wrong somewhere dince it don't write anything into the log file but its getting late and my brain has switch to eco mode 😅 I will look more into it tomorrow.
I'm running Debian strech but I didn't update it in a while. I also tried MD5 hashing by the way but nothing changed

@bilde2910
Copy link
Owner

I haven't been able to set up a VM yet, but I just thought I'd ask - is Docker an alternative for you? I've set up a Docker image that lets you run Hauk without having to install memcached and all that manually. A lot of things are going on so I don't think I can test with a VM tonight.

In the meantime, can you try to put the info.php file in your nginx root instead, and not running it via php -S? Can you also verify that memcached is running? E.g. sudo systemctl restart memcached.

bilde2910 added a commit that referenced this issue Aug 30, 2019
@RomanJos
Copy link
Author

RomanJos commented Aug 30, 2019

Hi sorry for the delay I forgot to remove .so in mods-available i only removed it in /etc/php/7.3/fpm/php.ini my bad. I have now zero error when I try service php7.3-fpm status and php7.3 -i | grep memcached give me memcached support => enabled as well as php-fpm7.3 -i | grep memcached.
I just can't have /info.php in my browser it send me a zero size response, if I try /info.phpv it reply 404 at intended so I think my fastcgi config in nginx is wrong but I don't know where

        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
          fastcgi_index index.php;
          include fastcgi_params;
        }
}

Do you have any idea ? And for a Docker image I think it will be the last resort for now if I can't setup a simple php server...lol
And by the way php-fpm write in /var/log/php7.3-fpm.log but nothing helpful just his pid and ready to accept connection

@bilde2910
Copy link
Owner

Can you double-check that you use the right unix socket path for php-fpm? Run grep php /proc/net/unix on your server and check that the path you get matches the one after fastcgi_pass unix: in your nginx config. If it doesn't, change the path in nginx and restart it.

@RomanJos
Copy link
Author

RomanJos commented Aug 30, 2019

  location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

I have now the info.php !
lol you are fast 😃 yes I did to be sure but it didn't helped

@bilde2910
Copy link
Owner

I have now the info.php !

That's great, that means PHP is working :-)

Double check that info.php says that memcached is active. Does Hauk work now?

@RomanJos
Copy link
Author

Screenshot_20190830_192600
Memcached work i'm trying to install Hauk from the f-droid website the app don't work
YES its working ! I'm so happy lol I'm having issue with OpenGapps it disable my GPS so I reset my phone this is why I needed to download hauk btw.
Thanks so much for your help and your work 🥇 !

@bilde2910
Copy link
Owner

Great to hear that it works now - happy to help :-)

By the way, I've completed work on an update to Hauk, v1.0.1. It's not live on the F-Droid store yet, though. Normally you'd get a notification through F-Droid when updates are released, but that won't happen if you don't have the store app. It has some improvements and bugfixes that you might like. So make sure to check back in a couple of days, hopefully it'll be live then. Have a good evening!

TheCataliasTNT2k pushed a commit to TheCataliasTNT2k/hauk that referenced this issue Apr 1, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants