diff --git a/docs/deployment.md b/docs/deployment.md index a907863..533069c 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -3,9 +3,9 @@ See the following docs for more info about strapi deployment: ### Setting up ntnu halfadministrated server -###### SSH +###### Firewall -We have created a firewall rule to allow remote ssh connections, such that we can remote in form a github runner and autodeploy. First we create a firewall rule: +We have created firewall rules to access website and api. `/etc/local/firewall.d $ touch ipv4-magnastr-docker-website-git-autodeply.conf` @@ -14,8 +14,14 @@ do `sudo nano ipv4-magnastr-docker-website-git-autodeply.conf` to enter the file paste the lines ``` --I INPUT -p tcp -m tcp --dport 22 -j ACCEPT -I INPUT -p tcp -m tcp --dport 3000 -j ACCEPT + +# Frontend (next.js node) Open TCP port 3000 for the world: +-I DOCKER-USER -p tcp -m conntrack --ctorigdstport 3000 -j ACCEPT + +# Backend (strapi) Open TCP port 1337 for world: +-I DOCKER-USER -p tcp -m conntrack --ctorigdstport 1337 -j ACCEPT + ``` ###### PKGSYNC diff --git a/frontend/.env.development b/frontend/.env.development index fb30a7b..45430ae 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,2 +1,4 @@ -# Database API URL -HOST_URL=http://localhost:1337 \ No newline at end of file +# Database url for outside requests +OUTSIDE_STRAPI_URL=http://localhost:1337 + +INTERNAL_STRAPI_URL=http://localhost:1337 \ No newline at end of file diff --git a/frontend/.env.production b/frontend/.env.production index e75b046..8bdef3f 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -1,2 +1,5 @@ -# Database url -HOST_URL=http://localhost:1337 +# Database url for outside requests, set in github repo variables +OUTSIDE_STRAPI_URL=http://web.hypso.ies.ntnu.no:1337 + +# Database url for internal requests between the docker containers, set in github repo variables +INTERNAL_STRAPI_URL=http://backend:1337 diff --git a/frontend/src/app/blog/[articleSlug]/page.tsx b/frontend/src/app/blog/[articleSlug]/page.tsx index ed51f56..c149149 100644 --- a/frontend/src/app/blog/[articleSlug]/page.tsx +++ b/frontend/src/app/blog/[articleSlug]/page.tsx @@ -5,7 +5,7 @@ import { BlocksContent } from "@strapi/blocks-react-renderer"; import BlockRendererClient from "@/components/BlockRendererClient"; import { gql } from "@/__generated__/gql"; import { getClient } from "@/lib/ApolloClient"; -const HOST_URL = process.env.HOST_URL; +const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; const GET_ARTICLE_BY_SLUG = gql( `query ArticleWithSlug($articlesFilters: ArticleFiltersInput) { @@ -71,8 +71,8 @@ export default async function Page({ graphqlData.data.articles?.data[0]?.attributes?.author?.data?.attributes ?.avatar?.data?.attributes?.url; - if (HOST_URL && avatarURL != undefined) { - avatarURL = HOST_URL + avatarURL; + if (OUTSIDE_STRAPI_URL && avatarURL != undefined) { + avatarURL = OUTSIDE_STRAPI_URL + avatarURL; } const article = graphqlData.data.articles?.data[0]; diff --git a/frontend/src/app/projects/[projectSlug]/page.tsx b/frontend/src/app/projects/[projectSlug]/page.tsx index e009fd3..24cc2e0 100644 --- a/frontend/src/app/projects/[projectSlug]/page.tsx +++ b/frontend/src/app/projects/[projectSlug]/page.tsx @@ -5,7 +5,7 @@ import { getClient } from "@/lib/ApolloClient"; import { BlocksContent } from "@strapi/blocks-react-renderer"; import RelatedProjectsAndSatellites from "@/components/RelatedProjectsAndSatellites"; import { ProjectOrSatellite } from "@/app/satellites/[satelliteSlug]/page"; -const HOST_URL = process.env.HOST_URL; +const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; const GET_PROJECT_BY_SLUG = gql(` query Projects($projectFilters: ProjectFiltersInput) { @@ -70,8 +70,8 @@ export default async function Page({ let projectTitle = projects?.attributes?.slug; - if (HOST_URL && projectTitle != undefined) { - projectTitle = HOST_URL + projectTitle; + if (OUTSIDE_STRAPI_URL && projectTitle != undefined) { + projectTitle = OUTSIDE_STRAPI_URL + projectTitle; } return (