fix: 配置端口代理與 TrustProxies
This commit is contained in:
@@ -3,10 +3,14 @@
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Http\Middleware\TrustProxies;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Spatie\Permission\Exceptions\UnauthorizedException;
|
||||
use Inertia\Inertia;
|
||||
|
||||
// 信任所有代理(用於反向代理環境)
|
||||
TrustProxies::at('*');
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
|
||||
@@ -11,7 +11,7 @@ services:
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
ports:
|
||||
- '${APP_PORT:-8080}:80'
|
||||
# - '${APP_PORT:-8080}:80' # 由 proxy 處理
|
||||
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
|
||||
environment:
|
||||
WWWUSER: '${WWWUSER}'
|
||||
@@ -75,7 +75,8 @@ services:
|
||||
image: 'nginx:alpine'
|
||||
container_name: star-erp-proxy
|
||||
ports:
|
||||
- '80:80'
|
||||
- '8080:8080'
|
||||
- '8081:8081'
|
||||
volumes:
|
||||
- './nginx/demo-proxy.conf:/etc/nginx/conf.d/default.conf:ro'
|
||||
networks:
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
# 總後台 (landlord) - 端口 8080
|
||||
server {
|
||||
listen 80;
|
||||
listen 8080;
|
||||
server_name 192.168.0.103;
|
||||
|
||||
# koori 租戶
|
||||
location /koori {
|
||||
proxy_pass http://star-erp-laravel:80;
|
||||
proxy_set_header Host koori.star-erp.demo:8080;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# 移除路徑前綴
|
||||
rewrite ^/koori/(.*) /$1 break;
|
||||
rewrite ^/koori$ / break;
|
||||
}
|
||||
|
||||
# 總後台(預設)
|
||||
location / {
|
||||
proxy_pass http://star-erp-laravel:80;
|
||||
proxy_set_header Host star-erp.demo:8080;
|
||||
proxy_set_header Host star-erp.demo;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host:$server_port;
|
||||
}
|
||||
}
|
||||
|
||||
# koori 租戶 - 端口 8081
|
||||
server {
|
||||
listen 8081;
|
||||
server_name 192.168.0.103;
|
||||
|
||||
location / {
|
||||
proxy_pass http://star-erp-laravel:80;
|
||||
proxy_set_header Host koori.star-erp.demo;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host:$server_port;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user