facebook twitter hatena line email

Linux/nginx/apache経由

提供: 初心者エンジニアの簡易メモ
2015年5月21日 (木) 05:49時点におけるAdmin (トーク | 投稿記録)による版 (動的処理はapacheに渡し、静的ファイルはapacheに渡さない)

移動: 案内検索

apacheに引き渡す際のreverse_proxy設定

  • /etc/nginx/conf.d/example.conf
server {
   listen       8090;
   server_name  example.localhost;
   location / {
           proxy_pass http://127.0.0.1:80;
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-Host $host;
           proxy_set_header X-Forwarded-Server $host;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   }
}

動的処理はapacheに渡し、静的ファイルはapacheに渡さない

server {
   listen       8090;
   server_name  example.localhost;
   location ~* \.(jpg|gif|png|swf|css|js|inc|ico)$ {
     root    /var/www/zend/example/public;
     index   index.html;
     ssi     on;
     break;
   }
   location / {
・・略・・

apache側port変更設定

  • /etc/httpd/conf/httpd.conf
Listen 80
Listen 8080
NameVirtualHost *:80
NameVirtualHost *:8080
  • /etc/httpd/conf/extra/example.conf
<VirtualHost *:8080>
・・略・・

mod_rpafのインストール

apacheのipが127.0.0.1になる問題回避で使用

$ sudo yum install httpd-devel
$ cd /usr/local/src
$ sudo wget https://raw.github.com/ttkzw/mod_rpaf-0.6/master/mod_rpaf-2.0.c --no-check-certificate
$ sudo /usr/sbin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
$ sudo vi /etc/httpd/conf.d/mod_rpaf.conf
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 10. 172.16.
RPAFheader X-Forwarded-For
$ sudo /etc/init.d/httpd restart