0
votes

Here is My Scenario.

I'm using ACM to generate 2 SSL certificates. example.com and *.example.com

I have 2 load balancers linked to the same EC2 instance.

1) Linked to my wordpress website - example.com

2) Linked to my app - *.example.com

Checklist I followed to troubleshoot outofservice error:

1) Instance State - Running

2) Status Checks - 2/2

3) Security Group Setting - Port 80/443/22 are open

4) Below are my Health Check settings

Ping Target - HTTP:80/ Timeout - 5 seconds Interval - 30 seconds Unhealthy threshold - 2 Healthy threshold - 10

I'm using NGINX webserver. I have checked the status, it shows its active.

Here is my config file example.com:

server
{
  server_name www. example.com;
  return 301 $scheme://example.com$request_uri;
}


server {

 listen       80;
 listen       443;

 server_name example.com;

 root /opt/bitnami/apps/wordpress/htdocs; 


}


server {

 listen       80;
 listen       443;

 server_name ~^(.*)\. example\.com$ ;

 root /opt/bitnami/apps/example_app;


}

What could be the problem here? Is the problem related to NGINX config settings or is it related to Load Balancer settings?

2
If you run curl within the instance are you getting expected html content? (for both your wordpress and app sites)Andrysha

2 Answers

0
votes

Your nginx settings are definitely not correct. There is no SSL at the instance level. Instead, the elb would terminate the SSL connection to the client. The only connection the ec2 instance should accept is on Port 80 and only from the elb. I suggest you remove the SSL report for for three references in nginx and make sure it's configured as above.

0
votes

You'll definitely need to configure nginx to run php scripts. Since php is a pre processing engine, your nginx configuration needs to know how to handle php files.

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

reference: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04

Since you mentioned this was a wordpress website, you'll need to setup a LEMP stack.