Reputation: 807
I'm currently trying to deploy a website in two directories. Despite the lot of documentations on it, I was not able to obtain the behavior that I wish. This is the architecture of the websites :
I wish configure nginx to obtain this behavior :
currently, my config file contains :
# redirect http to https
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
# main webiste
server {
listen 443;
# ssl elements...
root /opt/www/mainsite;
index index.html;
server_name www.mydomain.com;
location / {
try_files $uri $uri/ /index.html;
}
}
On this page I found all the informations to set the config file for CodeIgniter. But I don't know how to create the rules to point mydomain.com/myapp on the CodeIgniter folder and how to configure CodeIgniter in order to set the right configuration.
Is anybody can help me?
thanks in advance
Upvotes: 0
Views: 3254
Reputation: 9914
server { listen 80; server_name www.mydomain.com; return 301 https://$server_name$request_uri; } server { listen 443; server_name www.mydomain.com; # ssl elements... location / { root /opt/www/mainsite; index index.html; expires max; } location /myapp { root /opt/www/apps/myapp; # fastcgi module goes here... } }
Upvotes: 4
Reputation: 27218
server {
listen 80;
listen 443 ssl;
…
if ($scheme != "https") {
rewrite ^ https://$server_name$request_uri? redirect;
}
root /opt/www/mainsite/;
location /myapp {
root /opt/www/apps/myapp/;
}
}
You'd put whatever configuration that is necessary for your myapp
within the location
for myapp
.
BTW, it is generally a bad idea to host multiple independent apps within a single Host
, because of XSS concerns.
Upvotes: 0