2015-06-24 100 views
0

我有nginx和apache2在相同的Ubuntu服务器14.04,我想使用nginx作为代理服务器。我的想法是,当人们写www.mysite.com或www2.mysite.com重定向到Apache,我有相应的两个网站。Nginx和Apache2(代理服务器)

Nginx的是80端口和Apache是​​81端口

回答

1
server { 
     listen 80; 

     root /var/www/; 
     index index.php index.html index.htm; 

     server_name example.com www.example.com www1.example.com; 

     location/{ 
     try_files $uri $uri/ /index.php; 
     } 

     location ~ \.php$ { 

     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://127.0.0.1:81; 

     } 

     location ~ /\.ht { 
       deny all; 
     } 
} 

希望能给你的想法。