diff --git a/docker-compose.yml b/docker-compose.yml index 4191787ce..faa602e52 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,17 +17,19 @@ services: - "80/tcp" depends_on: - FilterLists.MariaDB -# FilterLists.Web: -# image: 'filterlists.web' -# build: -# context: src/FilterLists.Web + FilterLists.Web: + image: 'filterlists.web' + build: + context: src/FilterLists.Web + expose: + - "80/tcp" FilterLists.NGINX: image: 'nginx:stable-alpine' build: context: ./ops/nginx ports: - - '80:80' - - '443:443' + - '80:80/tcp' + - '443:443/tcp' links: - FilterLists.Api -# - FilterLists.Web \ No newline at end of file + - FilterLists.Web \ No newline at end of file diff --git a/ops/nginx/nginx.conf b/ops/nginx/nginx.conf index 3adbea35b..3a148667b 100644 --- a/ops/nginx/nginx.conf +++ b/ops/nginx/nginx.conf @@ -5,15 +5,21 @@ events { worker_connections 1024; } http { sendfile on; - upstream app_servers { - server FilterLists.Api:80; - } - server { listen 80; + location ^~ /api { + rewrite ^/api/(.*)$ /$1 break; + proxy_pass http://FilterLists.Api:80; + proxy_redirect off; + 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-Host $server_name; + } + location / { - proxy_pass http://app_servers; + proxy_pass http://FilterLists.Web:80; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; diff --git a/src/FilterLists.Web/ClientApp/Layout.tsx b/src/FilterLists.Web/ClientApp/Layout.tsx index 02c0e3c92..1f1736118 100644 --- a/src/FilterLists.Web/ClientApp/Layout.tsx +++ b/src/FilterLists.Web/ClientApp/Layout.tsx @@ -34,7 +34,7 @@ const Footer = () => ; const ApiLink = () => - API ; diff --git a/src/FilterLists.Web/ClientApp/modules/home/HomeContainer.tsx b/src/FilterLists.Web/ClientApp/modules/home/HomeContainer.tsx index ea15d3818..9e966e29f 100644 --- a/src/FilterLists.Web/ClientApp/modules/home/HomeContainer.tsx +++ b/src/FilterLists.Web/ClientApp/modules/home/HomeContainer.tsx @@ -41,49 +41,49 @@ export class HomeContainer extends React.Component<{}, IState> { }; fetchLanguages() { - fetch("https://filterlists.com/api/v1/languages") + fetch("/api/v1/languages") .then(r => r.json() as Promise) .then(p => { this.setState({ languages: p }); }); }; fetchLicenses() { - fetch("https://filterlists.com/api/v1/licenses") + fetch("/api/v1/licenses") .then(r => r.json() as Promise) .then(p => { this.setState({ licenses: p }); }); }; fetchLists() { - fetch("https://filterlists.com/api/v1/lists") + fetch("/api/v1/lists") .then(r => r.json() as Promise) .then(p => { this.setState({ lists: p }); }); }; fetchMaintainers() { - fetch("https://filterlists.com/api/v1/maintainers") + fetch("/api/v1/maintainers") .then(r => r.json() as Promise) .then(p => { this.setState({ maintainers: p }); }); }; fetchSoftware() { - fetch("https://filterlists.com/api/v1/software") + fetch("/api/v1/software") .then(r => r.json() as Promise) .then(p => { this.setState({ software: p }); }); }; fetchSyntaxes() { - fetch("https://filterlists.com/api/v1/syntaxes") + fetch("/api/v1/syntaxes") .then(r => r.json() as Promise) .then(p => { this.setState({ syntaxes: p }); }); }; fetchTags() { - fetch("https://filterlists.com/api/v1/tags") + fetch("/api/v1/tags") .then(r => r.json() as Promise) .then(p => { this.setState({ tags: p }); }); }; fetchRuleCount() { - fetch("https://filterlists.com/api/v1/rules") + fetch("/api/v1/rules") .then(r => r.json() as Promise) .then(p => { this.setState({ ruleCount: p }); }); }; diff --git a/src/FilterLists.Web/Dockerfile b/src/FilterLists.Web/Dockerfile index adb8f9af8..81ff5d7c8 100644 --- a/src/FilterLists.Web/Dockerfile +++ b/src/FilterLists.Web/Dockerfile @@ -1,10 +1,15 @@ FROM microsoft/dotnet:2.2-sdk-alpine AS publish -COPY FilterLists.Web /FilterLists.Web -RUN apk add --update nodejs-npm \ - && dotnet publish FilterLists.Web/FilterLists.Web.csproj -c Release -o /out +RUN apk add --update nodejs-npm + +WORKDIR /app +COPY FilterLists.Web.csproj . +RUN dotnet restore + +COPY . . +RUN dotnet publish -c Release -o /out FROM microsoft/dotnet:2.2-aspnetcore-runtime-alpine +WORKDIR /app COPY --from=publish /out . -ENV ASPNETCORE_URLS http://+:5001 -EXPOSE 5001 +ENV ASPNETCORE_URLS http://+:80 ENTRYPOINT ["dotnet", "FilterLists.Web.dll"] \ No newline at end of file diff --git a/src/FilterLists.Web/Program.cs b/src/FilterLists.Web/Program.cs index 6eefc54f8..82e198464 100644 --- a/src/FilterLists.Web/Program.cs +++ b/src/FilterLists.Web/Program.cs @@ -8,6 +8,6 @@ public static class Program public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); private static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args).UseUrls("http://localhost:5001;").UseStartup(); + WebHost.CreateDefaultBuilder(args).UseStartup(); } } \ No newline at end of file