From 47203915999b68822914e73fcd7d5724437ba22a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 28 Apr 2021 03:19:33 +0200 Subject: [PATCH] nginx fix for vue interface - localhost/vue resolves to frontend - localhost:3000/vue resolves to frontend in development - images are resolved properly - remaining services are reachable as normal - fixed image path to be relative instead of absolute - cleaned nginx config --- community_server/webroot/.htaccess | 1 + frontend/src/routes/router.js | 1 + frontend/src/views/KontoOverview/GddSend.vue | 2 +- frontend/vue.config.js | 2 +- nginx/nginx.conf | 73 +++++++------------- 5 files changed, 30 insertions(+), 49 deletions(-) diff --git a/community_server/webroot/.htaccess b/community_server/webroot/.htaccess index f5f2d631c..7f19fb980 100644 --- a/community_server/webroot/.htaccess +++ b/community_server/webroot/.htaccess @@ -1,5 +1,6 @@ RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !^/vue RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] diff --git a/frontend/src/routes/router.js b/frontend/src/routes/router.js index 6671a8de9..6d2963db5 100644 --- a/frontend/src/routes/router.js +++ b/frontend/src/routes/router.js @@ -6,6 +6,7 @@ Vue.use(VueRouter) // configure router const router = new VueRouter({ + base: '/vue', routes, // short for routes: routes linkActiveClass: 'active', mode: 'history', diff --git a/frontend/src/views/KontoOverview/GddSend.vue b/frontend/src/views/KontoOverview/GddSend.vue index 7230e6326..74acb3f46 100644 --- a/frontend/src/views/KontoOverview/GddSend.vue +++ b/frontend/src/views/KontoOverview/GddSend.vue @@ -10,7 +10,7 @@ - + diff --git a/frontend/vue.config.js b/frontend/vue.config.js index 3d196b0c7..0ff92c052 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -15,7 +15,7 @@ module.exports = { }, }, lintOnSave: true, - // publicPath: '/', + publicPath: '/vue', configureWebpack: { // Set up all the aliases we use in our app. resolve: { diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 4f3aff146..cfe30b2ac 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,5 +1,3 @@ - - server { listen 80 ; @@ -8,12 +6,10 @@ server { #include /etc/nginx/common/protect.conf; #include /etc/nginx/common/protect_add_header.conf; - #include /etc/nginx/common/ssl.conf; - + #include /etc/nginx/common/ssl.conf; root /var/www/cakephp/webroot; - index index.php; - + index index.php; location ~ \.php$ { fastcgi_pass community-server:9000; @@ -23,7 +19,6 @@ server { fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; include fastcgi_params; - } location ~ /\.ht { @@ -31,65 +26,49 @@ server { } location /account { - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_cache_bypass $http_upgrade; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $host; - rewrite /account/(.*) /$1 break; - - #proxy_next_upstream error timeout invalid_header http_502 non_idempotent; - proxy_pass http://login-server:1200; - proxy_redirect off; - + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + rewrite /account/(.*) /$1 break; + proxy_pass http://login-server:1200; + proxy_redirect off; } location /login_api { - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_cache_bypass $http_upgrade; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header Host $host; - rewrite /login_api/(.*) /$1 break; - - proxy_pass http://login-server:1201; - proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + rewrite /login_api/(.*) /$1 break; + + proxy_pass http://login-server:1201; + proxy_redirect off; } location / { - try_files $uri $uri/ /index.php?$args; + try_files $uri $uri/ /index.php?$args; } location /vue { - - location /vue/sockjs-node { - rewrite /vue/(.*) /$1; - } - location ~* \.(png) { - expires 1d; - rewrite /vue/(.*) /$1; - } - - #try_files /vue/$uri /vue/$uri/ /index.html; - proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; - #rewrite /vue/(.*) /$1 break; - - proxy_pass http://frontend:8080; + + proxy_pass http://frontend:3000; proxy_redirect off; } # access_log /var/log/nginx/access.log main; - } \ No newline at end of file