1

Update: Sorry, my bad. For android 8+ we should have clartextTraffic=true in androidManifest.xml for http to work. This was done/present in my app but after enabling https and domain setup, I deleted that since that wasn't needed anymore. But when I started testing again with http, it was not connecting as this entry was missing. I completely forgot about that part.

Anyways, I tried with my old apache server again to see if that was working after realising no errors in nginxerror.log. That was not working as well. Then I realised it is something on the app side that changed.I compared with history to check what changes I made.

In hindsight, I should have known earlier as http was working/connecting fine through browser. Funny thing is if I had tried directly over load balancer it would have worked properly since app will be using https and this setting is not required. Anyways, wasted two days but lesson learned.:). Thank you @JonnieJS for helping/replying.

Original qn: I have a laravel/php application which was working fine in apache but I thought it might be better to move to nginx to support larger concurrent users.

When trying through http, nginx access log is completely blank and error log shows a single line notice that signal process started. When enabling debug, I get the epoll add event lines as well. Laravel log is blank as well.

Funny thing is when I try through browser (even with http), I get the laravel default page (I cannot check application itself as it is mobile only). App is using okhttp for connection, so could be something to do with that. curl -v shows a similar response and html page as well.

This is my configuration file (domain/folder changed. Restarted server and tested multiple times after changes). The default nginx configuration file is unlinked.

Any idea what might be the issue or how to resolve this?

Justin
  • 11
  • 2

1 Answers1

0

I would suggest this plan:

AWS Load balancer with SSL certificates issued by AMAZON port 443. This will terminate SSL(HTTPS) and you should not care about it any more. Target group would issue all traffic in port 80 (HTTP) to instance with NGINX.

For the config look for this: https://laravel.com/docs/5.7/deployment#nginx

The actual instance should allow traffic only from the load balancer - from it's private IP. This will prevent to bypass your ELB.

If Laravel mistakenly thinks all URLs should use http:// instead of https:// you can try to look at URL::forceSchema('https');

Edit:

Please read more here: https://aws.amazon.com/blogs/aws/elastic-load-balancer-support-for-ssl-termination/

To make this more clear:

  1. client request https://exmaple.com/page-1 which resolves to 1.2.3.4 = the load balancer.
  2. Load balancer has SSL certificates, so it decrypt the traffic and send http traffic to the instance. so this looks like http://172.1.0.1/page-1
  3. NGINX has the following tasks:
    1. listen on port 80.
    2. pass the traffic to the handler (PHP or equivalent)

Hope this makes it more clear.

JonnieJS
  • 150
  • 5
  • It is http that is not working not https. And yes, using load balancer with http is the plan as mentioned in the question. – Justin Mar 29 '20 at 11:50
  • Please see my edit above. – JonnieJS Mar 30 '20 at 07:18
  • Hi @JonnieJS, nginx already configured to listen to port 80 and configured. But somehow it doesn't work. NGINX doesn't work with http. That is what I am asking in this qn. I know how load balancer work. That is why I am trying to connect using http. – Justin Mar 30 '20 at 08:38
  • If you know why nginx doesn't work for http (check configuration file in the qn) and know how to fix that let me know. – Justin Mar 30 '20 at 08:49
  • 1
    Please run `nginx -t` to check for problems. For what i'm seeing, this conf is okay. – JonnieJS Mar 30 '20 at 09:47
  • No errors in nginx -t. I check that after every conf change. I don't think it even hits the server since nothing in the error.log even with debug enabled. Any idea what epoll add event is? I am getting that after enabling error log debug mode. EC2 http ports are configured properly and ufw is disabled. – Justin Mar 30 '20 at 09:55
  • Have you set up Load balancer or you currently make requests directly? – JonnieJS Mar 30 '20 at 10:00
  • Testing directly, because I believe without http working no point in testing with load balancer. After allowing all traffic from all ports/protocols, I am getting a different set of debug messages. Can you please check this (updated in qn)? – Justin Mar 30 '20 at 10:38
  • The log shows fine behaviour with `200 success`. So whats exactly not working? – JonnieJS Mar 30 '20 at 10:57
  • I am still getting error at the front end (app) and it is not connecting. I don't know if it is an ec2 configuration error. But now both inbound and outbound are configured for all ports/protocols. – Justin Mar 30 '20 at 11:02
  • Can you check this link https://serverfault.com/questions/1010058/how-to-configure-nginx-for-json-support. I am getting a different error. I believe may be something to do with json configuration – Justin Mar 30 '20 at 11:04
  • NGINX has nothing to do with JSON support. The other question you mentioned just return 404 error from your application. – JonnieJS Mar 30 '20 at 11:10
  • Because if you check the url it is calling a "wt=json" args and /index.php?wt=json which isn't a valid url in the app. It shouldn't be doing that. – Justin Mar 30 '20 at 11:16
  • Sorry, my bad. Finally figured it. It was something else in the app that I changed. Updated in the qn above. Realising no errors in nginx error log should have been a clue. Thank you for help/support. – Justin Mar 30 '20 at 13:10
  • I'm glad to hear that. Consider accepting my answer if you find it helpful. – JonnieJS Mar 30 '20 at 16:33
  • @JonnieJS `sudo nginx -t` showed warnings which helped me resolve the issue. Great :) Thanks. – Megidd Jan 19 '22 at 04:02