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
    • 最新
    • 标签
主页 / server / 问题 / 783774
Accepted
anthony
anthony
Asked: 2016-06-14 21:14:08 +0800 CST2016-06-14 21:14:08 +0800 CST 2016-06-14 21:14:08 +0800 CST

谷歌负载均衡器 + nginx + symfony2

  • 772

我正在尝试配置一个可扩展的 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 1 个回答
  • 539 Views

1 个回答

  • Voted
  1. Best Answer
    anthony
    2017-01-03T14:32:37+08:002017-01-03T14:32:37+08:00

    阅读您的评论后,我认为这是我的问题@George

    您需要记住,如果检查运行状况失败,则不会重定向到特定实例。==>所以我为我的nginx创建了一个默认的conf(我在conf中添加了ssl)

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

    第二件事,您必须接受来自负载均衡器的流量和来自谷歌的健康检查到实例的端口 80(在我的情况下是 443)cf。

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

    我希望这对您有所帮助,如果您想了解更多详细信息,或者如果您有不明白的地方,请告诉我,我会尽力解释更多。

    PS:抱歉久等了

    • 0

相关问题

  • 网络负载平衡服务器无法相互通信

  • 用于网络监控的路由/代理 SNMP 陷阱(或 Netflow、通用 UDP 等)的解决方案?

  • 防止拒绝服务攻击的最佳技术是什么?

  • 添加备份互联网连接需要哪些硬件?

  • 什么是最有效的 Windows 负载平衡解决方案?

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