nginx 代理eureka後css/js/fonts無法訪問

BigOrang發表於2024-07-24

nginx 代理eureka後css/js/fonts無法訪問,頁面沒有樣式

server {
    listen 80;
    server_name your_domain.com;

    location /eureka {
        proxy_pass http://eureka_server_ip:8761;
        proxy_set_header Host $host;
        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;

        # Handle static resources under /eureka
        location ~ ^/eureka/(css|js|images|fonts)/ {
            proxy_pass http://eureka_server_ip:8761;
            proxy_set_header Host $host;
            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 the base URL to include /eureka
        rewrite ^/eureka/(.*)$ /$1 break;
    }
}

相關文章