如何解决如何通过 unix 套接字将 HTTP 和 Websockets 从 Apache 代理到 Gunicorn?
我的安装程序已经在我的虚拟主机中使用这两行通过 TCP 工作:
ProxyPassMatch ^/ws/.*$ ws://localhost:8000/
ProxyPass / http://localhost:8000/
现在我想使用 unix 套接字。所以我在前面加上了 unix:$SOCKETPATH|
并删除了端口:
ProxyPassMatch ^/ws/.*$ unix:/run/myapp.sock|ws://localhost/
ProxyPass / unix:/run/myapp.sock|http://localhost/
它适用于 HTTP,但 websocket 连接失败。我在 websockets 行中尝试了右侧的变体,例如:
ProxyPassMatch ^/ws/.*$ unix:/run/myapp.sock|ws:///
ProxyPassMatch ^/ws/.*$ unix:/run/myapp.sock|ws://
除了让它工作之外,我想了解为什么仍然需要管道 (|) 后面的部分?毕竟,Apache 应该只需要知道 unix 套接字路径,不是吗? Apache documentation on ProxyPass 没有解释这一点。
这些类似的问题没有帮助:
- Apache Reverse Proxy Unix Socket
- How to use Apache as a reverse-proxy for WebSockets with Undertow as the server
解决方法
我将 Debian Apache 数据包从 2.4.38-3+deb10u4(稳定)升级到 2.4.46-4~bpo10+1(反向移植),现在它可以工作了。 Apache 更改日志提到了对 websockets 的多项更改。我想这个变化可能是问题所在:
library(shiny)
library(tidyverse)
#UI:
ui <-
fluidPage(
navbarPage(
"TMC Calculator",tabPanel(
"About",fluidPage()
),tabPanel(
"Contact",selectInput("MP_type","Select the type of microplastic",choices=c("High Density Polyethylene" = "HDPE","Polycarbonate" = "PC","Polyethylene" = "PE","Polyethylene Terephthalate" = "PET","Polystyrene" = "PS","Polyvinylchloride" = "PVC")),selectInput("MP_shape","Select the shape of microplastic",choices=c("Long cylinder","Short cylinder","Sphere","Oblate spheroid (e=0.2)","Oblate spheroid (e=0.9)")),sliderInput("MP_size","Select the size of microplastic: ",min = 1,max = 5000,value = 100,step = 1),textInput("Contaminant","Enter the contaminant of concern","Antimony"),textInput("AC","Enter the contaminant adsorption capacity (mg/g)")
),plotOutput("TMC_curve")
)
#SERVER:
#Densities of microplastics
Microplastics_type <- data.frame(Microplastic = c("Polyethylene","Polypropylene","Polystyrene","Polyethylene Terephthalate","Polycarbonate","Polyvinylchloride","High Density Polyethylene"),Unit_volume = c(1.16,1.18,0.93,0.73,0.81,0.72,1.03))
#Contaminants and their corresponding minimum health endpoint parameters and adsorption capacities
Contaminant <- data.frame("Contaminant"= c("Aluminum","Antimony","Arsenic","BPA","Bromine","Cadmium","Chromium","Manganese","Mercury","Propanolol","Sulfamethoxazole"),"AC_la" = c(0.375,27.8,1.92,0.19,13,0.00014,0.000454,0.13,0.00125,0.133,0.087),"G" = c(2.9,0.004,0.003,0.00006,0.01,0.005,0.03,0.12,0.002,0.0005,0.02))
#Defining functions for surface area and volume of shapes (sphere,long & short cylinders and oblate spheroids (e = 0.2 and 0.9))
SPa <- function(d){4*pi*(d/2)^2}
SPv <- function(d){(4/3)*pi*(d/2)^3}
LCa <- function(d){10.5*pi*d^2}
LCv <- function(d){pi*(d/2)^2*(10*d)}
SCa <- function(d){0.6*pi*d^2}
SCv <- function(d){pi*(d/2)^2*(0.1*d)}
OSa <- function(d,e){2*pi*(d/2)^2 + (pi/e)*log((1+e)/(1-e))*((d/2)*(1-e^2)^0.5)^2}
OSv <- function(d,e){(pi/6)*d^3*sqrt(1-e^2)}
function(input,output,session){
d <- c(1,10,20,50,100,150,300,500,750)
a <- reactive({
if (as.character(input$MP_shape) == "Sphere"){
SPa(d)
} else if (as.character(input$MP_shape) == "Long Cylinder"){
LCa(d)
} else if (as.character(input$MP_shape) == "Short Cylinder"){
SCa(d)
} else if (as.character(input$MP_shape) == "Oblate Spheroid (e=0.2)"){
OSa(d,0.2)
} else if (as.character(input$MP_shape) == "Oblate Spheroid (e=0.9)"){
OSa(d,0.9)
}
})
v <- reactive ({
if (as.character(input$MP_shape) == "Sphere"){
SPv(d)
} else if (as.character(input$MP_shape) == "Long Cylinder"){
LCv(d)
} else if (as.character(input$MP_shape) == "Short Cylinder"){
SCv(d)
} else if (as.character(input$MP_shape) == "Oblate Spheroid (e=0.2)"){
OSv(d,0.2)
} else if (as.character(input$MP_shape) == "Oblate Spheroid (e=0.9)"){
OSv(d,0.9)
}
Microplastics_type_now <- Microplastics_type %>%
filter (Microplastic == input$MP_type )
TSA <- (1/(Microplastics_type_now$Unit_volume * v) * a)
Contaminant_now <- Contaminant %>%
filter (Contaminant == as.character(input$Contaminant) )
TMC <- Contaminant_now$G/(a*((Contaminant_now$AC_la/TSA)))
TMC_curve <- data.frame("TMC" = TMC,"Size" = d)
})
output$TMC_curve <- renderPlot({
ggplot(TMC_curve,aes(x = Size,y = TMC))+
geom_point()+
theme_bw()+
scale_y_log10()
})
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。