Plone 5.2 Set up virtual hosting 02

Plone 5.2 Set up virtual hosting We’re going to use nginx as a reverse proxy. Virtual hosting will be established by rewrite rules. You need two bits of information:

1) the hostname you want to use (for which DNS records should already be set up);

2) the id of the Plone site you created. First change the nginx default port,

sudo nano /etc/nginx/sites-available/default

Change default server listen port 80 to 8088 or something else and save Now We’ll set up nginx by adding a new configuration file:

sudo nano /etc/nginx/sites-available/plone5.conf

Add the contents for public domain or local domain

1. For public domain or local domain

server { 
server_name www.yourhostname.com; listen 80; 
location / { 
rewrite ^/(.*)$ /VirtualHostBase/http/www.yourhostname.com:
80/Plone/VirtualHostRoot/$1 break; proxy_pass http://localhost:8080; 
} location ~* manage_ { deny all; 
}
} 
server { 
server_name yourhostname.com; 
listen 80; 
access_log off; rewrite ^(/.*)$ http://www.yourhostname.com$1 permanent; 
} 

2. Local Lan/Intranet (Using ip only)

 

server { 
server_name 192.168.246.130; 
listen 80; 
location / { rewrite ^/(.*)$ /VirtualHostBase/http/192.168.246.130:80/Plone/VirtualHostRoot/$1 break; 
proxy_pass http://localhost:8080; 
} location ~* manage_ { deny all; 
} } 

location ~* manage_ rule will deny access to most of the Management interface. (You’ll get to that by bypassing nginx.)
The second server stanza sets up an automatic redirect that will transfer requests for the bare hostname to its www. form. You may not want or need that. Enable the new nginx site configuration:

cd /etc/nginx/sites-enabled 
sudo ln -s /etc/nginx/sites-available/plone5.conf 

And, tell nginx to reload the configuration:

 

sudo service nginx configtest 
sudo service nginx reload 

Try out your virtual hosting.

Leave a Reply

Your email address will not be published. Required fields are marked *