简体   繁体   English

PHP Elastic Beanstalk环境的自定义Nginx配置

[英]Custom nginx config for PHP Elastic Beanstalk environment

I have a web server environment that uses a PHP preconfigured platform. 我有一个使用PHP预配置平台的Web服务器环境。 I want to nginx to pass the request to a proxy server. 我想让Nginx将请求传递给代理服务器。 Here's what I have in .ebextensions/nginx.config : 这是我在.ebextensions/nginx.config

files:
  "/etc/nginx/conf.d/000_my_config.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      server {
        sub.mysite.com;
        listen 80;

        location = / {
          rewrite ^ http://www.google.com;
        }

        location / {
          proxy_pass http://****.elasticbeanstalk.com;
        }
      }

File /etc/nginx/conf.d/000_my_config.conf is created on the server. 在服务器上创建文件/etc/nginx/conf.d/000_my_config.conf When I visit sub.mysite.com I am not directed to Google but instead my app, so it seems the nginx config is not loaded. 当我访问sub.mysite.com我没有定向到Google,而是定向到了我的应用程序,因此似乎未加载nginx配置。 I've seen other answers that state to do sudo service nginx reload to restart nginx, but I get nginx: unrecognized service . 我已经看到其他答案,指出要执行sudo service nginx reload以重新启动nginx,但是我得到了nginx: unrecognized service

Does your server have a file at /opt/elasticbeanstalk/support/conf/nginx_config.erb ? 您的服务器是否在/opt/elasticbeanstalk/support/conf/nginx_config.erb有一个文件? The Ruby version of ElasticBeanstalk uses that file to configure nginx. Ruby版本的ElasticBeanstalk使用该文件来配置nginx。

If the PHP version is the same, then you should be able to insert your configuration there, although you'll want to do it using sed rather than installing a whole new file. 如果PHP版本相同,那么您应该可以在其中插入配置,尽管您希望使用sed而不是安装整个新文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM