我有一个safe-stack application(默认计数应用程序)部署为在服务器上运行的docker容器。我可以使用Plesk管理服务器。使用Plesk,我可以创建代理规则,以便将诸如:host / subdomain之类的请求重新路由到正在运行的docker容器端口,例如8085。 但是,容器中正在运行的Saturn服务器正在接收的请求不是这样的:
Request starting HTTP/1.1 GET http://localhost:8085/ Sending file. Request path: '/index.html'. Physical path: '/Client/public/index.html' Request finished in 0.8357ms 200 text/html
但是:
Request starting HTTP/1.0 GET http://somedomain.net/sub_domain/ Request finished in 110.3886ms 404
我得到404。
因此,我想以某种方式http://somedomain.net/sub_domain
作为我的服务器应用程序的“根” URL,并使用该根URL解析静态文件请求。
应用设置如下:
open System.IO
open System.Threading.Tasks
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.DependencyInjection
open FSharp.Control.Tasks.V2
open Giraffe
open Saturn
open Shared
let tryGetEnv = System.Environment.GetEnvironmentVariable >> function null | "" -> None | x -> Some x
let publicPath =
Path.GetFullPath "../Client/public"
|> fun s -> printfn "Using public path: %s" s; s
let port = "SERVER_PORT" |> tryGetEnv |> Option.map uint16 |> Option.defaultValue 8085us
let getInitCounter() : Task<Counter> = task { return { Value = 42 } }
let initHandler =
fun next ctx ->
task {
let! counter = getInitCounter()
return! json counter next ctx
}
let webApp = router {
get "/api/init" initHandler
}
let configureSerialization (services:IServiceCollection) =
services.AddSingleton<Giraffe.Serialization.Json.IJsonSerializer>(Thoth.Json.Giraffe.ThothSerializer())
let app = application {
url ("http://0.0.0.0:" + port.ToString() + "/")
use_router webApp
memory_cache
use_static publicPath
service_config configureSerialization
use_gzip
}
run app
我该如何管理而无需使用子域对网址进行硬编码。