To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Verified Commit f9b58cc9 authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Add media proxy to nginx configuration

parent 92d9886e
Pipeline #82932 passed with stages
in 11 minutes and 29 seconds
......@@ -22,12 +22,17 @@ RUN npm install -g gatsby-cli
# Build project
RUN npm run $NPM_BUILD_COMMAND
# Prepare nginx configuration
RUN /bin/bash -c 'if [[ "${NPM_BUILD}" == "build" ]]; \
then export AMIVAPI_URL="https://api.amiv.ethz.ch"; \
else export AMIVAPI_URL="https://api-dev.amiv.ethz.ch"; \
fi && \
sed -i "s|AMIVAPI_URL|${AMIVAPI_URL}|" nginx.conf'
# Second stage: Server to deliver files
FROM nginx:1.15-alpine
# Copy files from first stage
COPY --from=build /gatsby/public /var/www
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /gatsby/nginx.conf /etc/nginx/conf.d/default.conf
......@@ -20,6 +20,14 @@ server {
add_header Cache-Control "no-cache";
}
location /media {
# Do not allow caching of media files from api.
add_header Cache-Control "no-cache";
rewrite /media/([0-9a-z]+)(?:/(.*)) /media/$1 break;
proxy_pass AMIVAPI_URL;
proxy_redirect off;
}
location ~* /(en|de)/404/index.html {
internal;
}
......
......@@ -7,7 +7,6 @@ import { useIntl, navigate, FormattedMessage } from 'gatsby-plugin-intl'
import fileSize from 'filesize'
import { FileTypeIcon, CopyButton } from 'amiv-react-components'
import { apiUrl } from 'config'
import { deleteItem } from '~store/common/actions'
import { STUDYDOCUMENTS } from '~store/studydocuments/constants'
......@@ -110,7 +109,7 @@ const StudydocumentDetails = ({ studydocumentId, ...props }) => {
<a
key={name}
className={classes.documentLink}
href={`${apiUrl}${file}`}
href={`${file}/${name}`}
target="_blank"
rel="noopener noreferrer"
onClick={e => e.stopPropagation()}
......
......@@ -265,7 +265,11 @@ const StudydocumentForm = ({ studydocumentId, className, ...props }) => {
const fileUrl = item.info.file
const filename = item.info ? item.info.name : item.file.name
return (
<ExternalLink noIcon href={fileUrl} download={filename}>
<ExternalLink
noIcon
href={`${fileUrl}/${filename}`}
download={filename}
>
<FormattedMessage id="studydocuments.actions.download" />
</ExternalLink>
)
......
......@@ -172,7 +172,7 @@ const StudydocumentSummary = ({ studydocumentId, ...props }) => {
<a
key={name}
className={classes.documentLink}
href={`${apiUrl}${file}`}
href={`${file}/${name}`}
target="_blank"
rel="noopener noreferrer"
onClick={e => e.stopPropagation()}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment