网络上的许多信息告诉我们如何在同一台机器上设置nginx + application mono-server4 4,以便从linux环境中承载ASP.net (目前我正在使用F#应用程序和Websharper)。但是码头应该只运行一个进程。此外,还可以使用runit或其他工具在同一个容器上运行nginx和mono服务器。
我让它在同一个容器中工作,但是当我尝试将web应用程序+快速web mono-server4 4移动到另一个容器时,我得到了
[error] 12#12: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.99.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.17.0.40:32775", host: "192.168.99.100:32786"找到了一个关于类似需求的文章,但是对于php快速fpm服务器(Php)来说,它只适用于链接容器。但是对于快速单服务器来说却不是。
我尝试创建了一个包含快速run mono - server 4+应用程序文件的容器,公开了大量应用程序文件,公开了端口9000,然后nginx容器包含来自第一个容器的卷并链接到它,并且尝试运行两个安装了nginx和mono服务器的容器,第一个容器安装了fastcgi_pass 127.0.0.1:9000,第二个容器使用了fastcgi_pass 172.17.0.40:32775 - ip并从第一个容器运行端口。如果访问第一个容器-应用程序有效,访问第二个容器-与上面相同的错误。
Comand用于运行mono服务器:
fastcgi-mono-server4 /printlog=True /applications=/:/var/www/websharper/ /socket=tcp:0.0.0.0:9000 /loglevels=All /verbose=True已安装软件的版本:
Container from mono (debian wheezy with mono:4.0.0)
NGINX_VERSION 1.9.5-1~wheezy
$ mono --version
Mono JIT compiler version 4.0.3 (Stable 4.0.3.20/d6946b4 Tue Aug 4 09:43:57 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
$ fastcgi-mono-server4 --version
Mono.WebServer2.dll 0.4.0.0来自快速logs mono-server4 4启动的一些日志
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.510407] Debug : fastcgi-mono-server4
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.530481] Debug : Uid 0, euid 0, gid 0, egid 0
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.531310] Debug : Root directory: /
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.532843] Notice : Adding applications '/:/var/www/websharper/'...
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.533478] Notice : Registering application:
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.533757] Notice : Host: any
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.534075] Notice : Port: any
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.534459] Notice : Virtual path: /
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.534770] Notice : Physical path: /var/www/websharper/
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.543250] Debug : Parsed tcp:0.0.0.0:9000 as URI tcp:0.0.0.0:9000
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.556826] Debug : Listening on port: 9000
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.558991] Debug : Listening on address: 0.0.0.0
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.564079] Debug : Max connections: 1024
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.564786] Debug : Max requests: 1024
9: 1 fastcgi-mono-server [2015-10-01 09:01:17.565224] Debug : Multiplex connections: False
9: 3 fastcgi-mono-server [2015-10-01 09:01:17.568840] Debug : Server started [callback: Mono.WebServer.FastCgi.ServerProxy]在mono的顶部:4.0.0安装了码头映像:
apt-get install -y ca-certificates nginx=1.9.5-1~wheezy
apt-get install -qy mono-fastcgi-server4
apt-get install -qy mono-xsp4
apt-get install -qy fsharp此外,我还确保将mono 4.5用于应用程序:
sed -ie 's|mono/4.0|mono/4.5|g' /usr/bin/fastcgi-mono-server4 \
&& sed -ie 's|mono/4.0|mono/4.5|g' /usr/bin/xsp4还有我的nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80 default;
access_log /dev/stdout;
error_log /dev/stdout;
root /var/www/websharper;
index main.html;
location / {
root /var/www/websharper/;
fastcgi_pass 172.17.0.40:32775;
include /etc/nginx/fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}最后是fastcgi_params
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;更新:
我在消息来源中发现,如果您选择任何ip,TcpSocket将分配回退ip.这很奇怪..。
class TcpSocket : StandardSocket {
public TcpSocket (System.Net.IPEndPoint localEndPoint)
: base (System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream,
System.Net.Sockets.ProtocolType.IP, localEndPoint)
{
}
public TcpSocket (System.Net.IPAddress address, int port)
: this (new System.Net.IPEndPoint (Equals(address, System.Net.IPAddress.Any) ?
System.Net.IPAddress.Loopback : address, port))
{
}
}无论如何,我已经尝试将set ip地址直接用于mono服务器(通过将nginx容器链接到mono容器)。
fastcgi-mono-server4 /printlog=True /applications=/:/var/www/websharper/ /socket=tcp:$(printenv NGINX_HOST_PORT_80_TCP_ADDR):9000 /loglevels=All /verbose=True运行这个盒子
docker run --name t2 --link t1:nginx_host -it -P vasylpurchel/docker-websharper如果t1是一个运行nginx的盒子,那么这个测试也失败了:
root@dc540db6577f:/# 8: 1 fastcgi-mono-server [2015-10-02 14:32:05.147774] Debug : fastcgi-mono-server4
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.154128] Debug : Uid 0, euid 0, gid 0, egid 0
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.155000] Debug : Root directory: /
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.156562] Notice : Adding applications '/:/var/www/websharper/'...
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.157182] Notice : Registering application:
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.157457] Notice : Host: any
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.157908] Notice : Port: any
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.158195] Notice : Virtual path: /
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.158489] Notice : Physical path: /var/www/websharper/
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.169995] Debug : Parsed tcp:172.17.0.5:9000 as URI tcp:172.17.0.5:9000
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.181117] Debug : Listening on port: 9000
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.182573] Debug : Listening on address: 172.17.0.5
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.186638] Debug : Max connections: 1024
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.187418] Debug : Max requests: 1024
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.187767] Debug : Multiplex connections: False
8: 1 fastcgi-mono-server [2015-10-02 14:32:05.192868] Error : Failed to start server Mono.WebServer.FastCgi.Sockets. TcpSocket: The requested address is not valid in this context (10049)
Unhandled Exception:
System.Net.Sockets.SocketException: The requested address is not valid in this context
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in <filename unknown>:0
at Mono.WebServer.FastCgi.Sockets.StandardSocket.Listen (Int32 backlog) [0x00000] in <filename unknown>:0
at Mono.WebServer.FastCgi.GenericServer`1[Mono.WebServer.FastCgi.ConnectionProxy].Start (Boolean background, Int32 backlog) [ 0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: The requested address is not valid in this context
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in <filename unknown>:0
at Mono.WebServer.FastCgi.Sockets.StandardSocket.Listen (Int32 backlog) [0x00000] in <filename unknown>:0
at Mono.WebServer.FastCgi.GenericServer`1[Mono.WebServer.FastCgi.ConnectionProxy].Start (Boolean background, Int32 backlog) [0x00000] in <filename unknown>:0地址172.17.0.5是一个运行在nginx上的容器的IpAddress。
发布于 2016-10-02 17:17:10
当使用参数时,快速use mono-server4 4对带有侦听地址的docker容器有限制。
要修复快速the mono-server4 4行为,必须在套接字参数中使用docker容器IP地址。
您需要修复Docker容器中的命令
fastcgi-mono-server4 /applications=/:/var/www/websharper/ /socket=tcp:$(ip -4 addr show eth0| grep -Po 'inet \K[\d.]+'):9000这是Dockerfile修复的一个示例
FROM mono:latest
RUN apt-get update
RUN apt-get install -y mono-fastcgi-server4
RUN rm -rf /var/lib/apt/lists/* /tmp/*
RUN echo "#!/bin/sh\nfastcgi-mono-server4 /applications=/:/var/www/websharper/ /socket=tcp:\$(ip -4 addr show eth0| grep -Po 'inet \K[\d.]+'):9000" > /opt/mono-fastcgi
RUN chmod +x /opt/mono-fastcgi
EXPOSE 9000
CMD [ "/opt/mono-fastcgi" ]https://stackoverflow.com/questions/32886347
复制相似问题