in my case have two yii2 appliation and want to configure in such way that i can access both application like below.
app 1 frontend - somedomain.com/app1/
app 1 backend - somedomain.com/app1/admin
app 2 frontend - somedomain.com/app2/
app 2 backend - somedomain.com/app2/admin
what i have tried.
i have created 5 nginx config file defualt.conf, app1-frontend.conf, app1-backend.conf, app2-frontend.conf, app2-backend.conf
defualt.conf
server {
listen 80;
server_name somedomain.com;
location /app1 {
proxy_pass http://localhost:3000;
}
location /app1/admin {
proxy_pass https://localhost:3001;
}
location /app2 {
proxy_pass http://localhost:5000;
}
location /app2/admin {
proxy_pass https://localhost:5001;
}
}
app1-frontend.conf
server {
charset utf-8;
client_max_body_size 128M;
listen 3000;
server_name 127.0.0.1 localhost;
root /home/dev/Desktop/app1/frontend/web;
access_log /home/dev/Desktop/app1/vagrant/nginx/log/frontend-access.log;
error_log /home/dev/Desktop/app1/vagrant/nginx/log/frontend-error.log;
location / {
index index.html index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
location ~ \.php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
try_files $uri =404;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
and for other config like app1-backend.conf, app2-frontend.conf, app2-backend.conf
everything is same except port and the document root.
when i visit http://somedomain.com/app1/
i got only html page and in other appliation routes got 404
and for http://somedomain.com/app1/admin
i got 502
error.
does anyone know how to solve it?
What you should google is called SSO (single sing on). If you use 3rd party authentication provider (like OAuth) you can achieve the desired behaviour - I got such env. up and running with JWT (JSON wet token) and Auth0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.