AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-360410

anthony's questions

Martin Hope
anthony
Asked: 2017-01-03 14:50:20 +0800 CST

谷歌负载均衡器的问题,用户没有发送到最近的实例

  • 0

我在 Google Cloud Platform 中创建了 6 个实例

  • 亚洲 2
  • 2 在我们
  • 2 在欧洲

我在每个区域有 3 个组

当我尝试使用我的应用程序时,我会随机发送到一个区域,无论我是在欧洲还是其他地方。

有关信息,我遵循了此文档https://cloud.google.com/compute/docs/load-balancing/http/cross-region-example

我只是添加一个区域并删除 http conf。

6个实例上没有流量,只有我。所有 6 个实例都可用,并且运行状况检查是肯定的。

这是我刚刚刷新页面时的最后一个结果:

  1. 亚洲
  2. 欧洲
  3. 我们
  4. 欧洲
  5. 亚洲
  6. 亚洲

如果您有任何想法或需要更多详细信息来帮助我,请询问,我会的。

更新 1

在每种情况下,我都有一个带有一个默认 conf 的 nginx:

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;
    }
}

然后我有我的应用程序配置:

server {
    listen 443 ssl;
    server_name myapp.example.com www.myapp.example.com;
    ssl_certificate /etc/nginx/ssl/secure.crt;
    ssl_certificate_key /etc/nginx/ssl/mysecure.key;

    root /usr/share/nginx/html/app/web;

    error_log /var/log/nginx/myapp.example.com_error.log;
    access_log /var/log/nginx/myapp.example.com.log;

    if ($http_x_forwarded_proto = "http") { 
        return 301 https://$host$request_uri; 
    }

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app.php$is_args$args;
    }
    # PROD
    location ~ ^/app\.php(/|$) {
        fastcgi_pass php:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }
}

当我去https://ip-load-balancer时,它工作得很好,总是得到最近的实例。

但是当我尝试https://myapp.example.com时,它出错了,我可以在日志中看到有一些重定向。此外,当我检查负载均衡器的日志时,他将请求发送到好的实例,但是我不明白如何遵循请求。

谢谢

load-balancing google-cloud-platform nginx docker
  • 1 个回答
  • 110 Views
Martin Hope
anthony
Asked: 2016-06-14 21:14:08 +0800 CST

谷歌负载均衡器 + nginx + symfony2

  • 2

我正在尝试配置一个可扩展的 symfony2 应用程序,所以我阅读了这个页面https://cloud.google.com/compute/docs/load-balancing/http/cross-region-example

我做了他们所说的每一件事,正在使用一个简单的 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
    }
}

有了这个我得到一个积极的检查健康,如果我尝试http://ip_load_balancer我得到了 nginx 的默认页面。

但是当我尝试我真正的 nginx 的 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;
}
}

当我尝试http://ip_load_blancer时,我得到 502 服务器错误。但是当我尝试http://ip_vm1时,我得到了我的应用程序(我打开了所有的 http 访问来测试)。

此外,所有检查运行状况均失败。我真的不明白怎么了,有什么想法吗?

谢谢。

load-balancing nginx google-compute-engine symfony
  • 1 个回答
  • 539 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve