2015-06-24 99 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; 
     } 
} 

希望能給你的想法。