将ngnix rails conf转换为Apache

时间:2018-06-27 06:12:49

标签: ruby-on-rails 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配置中指定套接字。请帮忙。

1 个答案:

答案 0 :(得分:0)

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

以下是默认httpd.conf文件中的内容(我正在使用的apache2安装中的/etc/apache2/中提供了该内容-尽管不同的安装/系统将config目录放置在其他位置)

# 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 documentation中的NameVirtualHostVirtualHost指令的说明