2

i'm trying to configure a scalable symfony2 app, so i read this page https://cloud.google.com/compute/docs/load-balancing/http/cross-region-example

i did every thing like they said, is working with a simple nginx conf :

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }
}

with that i get a positive check health and if i try http://ip_load_balancer i get the nginx's default page.

But when i try my real nginx's conf:

server {
listen 80;
server_name myapp-public.com;
root /usr/share/nginx/html/app-public/web;


recursive_error_pages off;

error_log /var/log/nginx/app_error.log;
access_log /var/log/nginx/app_access.log;

location / {
    try_files $uri /app.php$is_args$args;
}

# PROD
location ~ ^/app\.php(/|$) {
    internal;
    fastcgi_pass php:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_index  index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
    fastcgi_intercept_errors on;
}
}

When i try http://ip_load_blancer, i get 502 Server Error. But when i try http://ip_vm1, i get my application (i open the http access from all to test).

Also all the check health fail. I don't really understand what's wrong, any idea?

Thanks.

anthony
  • 21
  • 3
  • On what port have you configured your health checks ? – Faizan Jun 14 '16 at 21:06
  • i have configured port 80 – anthony Jun 15 '16 at 03:53
  • Do you have a path configured for health check? If yes, can you try to replace the path with a static HTML page and see whether the health check is successful ? – Faizan Jun 16 '16 at 14:09
  • I have the same issue and also getting 502. I can access the app with the IP of the instance but not with the load balancer frontend IP. (See http://stackoverflow.com/q/38052185/454103). Did you find a solution to your problem? (Other than moving to AWS) – Gabriel Petrovay Jun 28 '16 at 16:24
  • Not yet. I will work on it again in 2 weeks so i will keep you inform. – anthony Jul 31 '16 at 06:50
  • It's now working. I need to document my solution then i will post the link. – anthony Sep 01 '16 at 12:53
  • @anthony it looks like you were able to resolve your issue. Is it possible to post the answer and accept it so other people can benefit from it – George Nov 23 '16 at 18:21

1 Answers1

0

After reading your comment here is what i think was my problem @George

You need to keep in mind that if the check health failed, there will be no redirect to the specific instance. ==> So i create a default conf for my nginx (i add ssl in the conf)

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}



server {
    listen 443 ssl;
    server_name _;
    ssl_certificate /etc/nginx/ssl/secure.crt;
    ssl_certificate_key /etc/nginx/ssl/mysecure.key;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
}

Second things, you have to accept traffic from your load balancer and health check from google to the instance's port 80 (and 443 in my case) cf.

==> https://cloud.google.com/compute/docs/load-balancing/http/cross-region-example#shutting_off_https_access_from_everywhere_but_the_load_balancing_service

I hope this help you, if you want more details, or if you don't understand something, just tell me, i will try to explain more.

PS : Sorry for the wait

anthony
  • 21
  • 3