如何在 Elastic Beanstalk 环境中运行的乘客独立上启用“ngx_http_realip_module”?
Posted
技术标签:
【中文标题】如何在 Elastic Beanstalk 环境中运行的乘客独立上启用“ngx_http_realip_module”?【英文标题】:How to enable "ngx_http_realip_module" on passenger-standalone running on Elastic Beanstalk environment? 【发布时间】:2017-08-29 08:52:15 【问题描述】:我正在尝试在我的 Elastic Beanstalk 环境的 http
块内使用选项 set_real_ip_from
,但收到此错误:
$ service passenger restart
*** ERROR *** Could not start Passenger nginx core: nginx: [emerg] unknown directive "set_real_ip_from" in
Beanstalk 正在使用嵌入 nginx 的乘客独立:
$ gem list |grep passenger
passenger (4.0.60)
$ /opt/elasticbeanstalk/bin/get-config container -k nginx_version
1.8.1
我尝试使用 gem install passenger
将乘客更新到更新版本:
$ gem install passenger
Fetching: passenger-5.1.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed passenger-5.1.2
Parsing documentation for passenger-5.1.2
Installing ri documentation for passenger-5.1.2
Done installing documentation for passenger after 48 seconds
1 gem installed
但是在重新启动乘客时,我收到了这个:
---------------------------------------
No precompiled Nginx engine could be downloaded. Compiling it from source instead.
--------------------------------------------
Checking for required software...
* Checking for C compiler...
Found: yes
Location: /usr/bin/cc
* Checking for C++ compiler...
Found: yes
Location: /usr/bin/c++
* Checking for GNU make...
Found: yes
Location: /usr/bin/gmake
* Checking for Rake (associated with /opt/rubies/ruby-2.3.1/bin/ruby)...
Found: yes
Location: /opt/rubies/ruby-2.3.1/bin/ruby /opt/rubies/ruby-2.3.1/bin/rake
* Checking for OpenSSL development headers...
Found: yes
Location: /usr/include/openssl/ssl.h
* Checking for Zlib development headers...
Found: yes
Location: /usr/include/zlib.h
* Checking for PCRE development headers...
Found: yes
Location: /usr/include/pcre.h
Installing...
Downloading Nginx 1.8.1 source code...
######################################################################## 100.0%
Extracting tarball...
Compiling support libraries (step 1 of 2)...
[**************************************************] -
Compiling Nginx engine (step 2 of 2)...
[************ ] \
./configure: error: invalid option "--with-http_v2_module"
*** ERROR: command failed: cd /tmp/passenger-install.wmn75y/nginx-1.8.1 && env PASSENGER_INCLUDEDIR=/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/passenger-5.1.2/src PASSENGER_LIBS=/tmp/passenger-install.wmn75y/common/libpassenger_common/Logging.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Exceptions.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Utils/SystemTime.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Utils/StrIntUtils.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Utils/StrIntUtilsNoStrictAliasing.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Utils/IOUtils.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Utils.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/WatchdogLauncher.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/AppTypes.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/Utils/CachedFileStat.o\ /tmp/passenger-install.wmn75y/common/libpassenger_common/UnionStationFilterSupport.o\ /tmp/passenger-install.wmn75y/common/libboost_oxt.a /bin/bash ./configure --prefix=/tmp --with-cc-opt=-Wno-error --without-http_fastcgi_module --without-http_scgi_module --without-http_uwsgi_module --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --add-module=/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/passenger-5.1.2/src/nginx_module
如何重新编译这个嵌入式 nginx 或者有没有其他简单的方法来启用这个模块?
这只是我通过
.ebextension
永久完成之前的测试
【问题讨论】:
【参考方案1】:这似乎是乘客的问题。 这是一个如何修改构建配置的想法: https://github.com/phusion/passenger/commit/e59af13629c8de1ea6ce509cec0fad7538860643
【讨论】:
事实上这是问题所在,但这并不能解决问题。如问题中所述:beantalk 正在使用旧版本的 nginx 并且更新乘客给我们带来了问题。以上是关于如何在 Elastic Beanstalk 环境中运行的乘客独立上启用“ngx_http_realip_module”?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Elastic Beanstalk 环境中查看 EC2 内部的环境属性?
如何在Linux中每行字符后自动引用内容? (Elastic Beanstalk 环境变量相关)
如何在 aws elastic beanstalk 环境实例启动上运行 shell 脚本
如何通过 RDS 复制到 Elastic Beanstalk 克隆