首页 > 解决方案 > 将 ngnix rails conf 转换为 apache

问题描述

我正在尝试在生产服务器中设置 apache。我的 nginx 配置如下所示。

upstream puma {
   server unix:///var/www/rails/shared/tmp/sockets/puma.sock;
}

server {
   listen 80 default_server deferred;
   # server_name example.com;

   root /var/www/rails/current/public;
   access_log /var/www/rails/current/log/nginx.access.log;
   error_log /var/www/rails/current/log/nginx.error.log info;

   location ^~ /assets/ {
     gzip_static on;
     expires max;
     add_header Cache-Control public;
   }

   try_files $uri @puma;
   location @puma {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;

      proxy_pass http://puma;
   }

   error_page 500 502 503 504 /500.html;
   client_max_body_size 10M;
   keepalive_timeout 10;
}

但我找不到如何在 httpd 配置中指定套接字。请帮忙。

标签: ruby-on-railsapache

解决方案


要设置 Apache 服务器侦听的端口,请使用该Listen指令。

这是它在默认httpd.conf文件中所说的内容(在/etc/apache2/我正在使用的 apache2 安装中找到 - 尽管不同的安装/系统将配置目录放在其他位置):

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
#Listen 66.18.208.111:80
#Listen 66.18.208.112:80
Listen 80

如果您使用命名虚拟主机(一台服务器上的多个网站),您将希望在Apache 2.2 vhosts 文档NameVirtualHost中查看和VirtualHost指令的说明


推荐阅读