如何configurationnginx作为代理到docker?

如何configurationnginx作为代理到docker?,第1张

概述如何configurationnginx作为代理到docker?

我一直试图设置Nginx作为docker的代理。 我想做一些解释在这个答案,但docker不响。

我创build了一个.war ,并将其放入~/jetty/jetty-dist/webapps/web_test-0.1.0-SNAPSHOT-standalone.war

说,我想使用域名example.com与IP地址198.51.100.0。

我还将/etc/Nginx/sites-available/default复制到了example.com文件中,并将其放在同一目录中。

你能帮我configurationNginx作为我的代码到docker吗? 我知道有很多关于如何做到这一点的网上参考,但他们都是不同的,我感到困惑。

我需要在Nginx中做什么具体的修改? 在jetty.xml中需要做什么修改? 我是否需要进行其他更改? 我的应用程序将在example.com/index.HTML提供吗?

Nginx的当前状态复制如下:

upstream jetty { server 127.0.0.1:8080 fail_timeout=0 } server { Listen 80 default_server; #Listen [::]:80 default_server ipv6only=on; root /usr/share/Nginx/HTML; index index.HTML index.htm; server_name localhost; location / { proxy_pass http://jetty try_files $uri $uri/ =404; }

编辑

我想知道是否需要使用Jetty。 在这个设置中,他只是使用戒指,这似乎超级简单? 我使用jetty获得什么?

如何配置Nginx以使用java服务器。 在示例中使用Jetty。

编辑/etc/Nginx/sites-available/hostname :

server { Listen 80; server_name hostname.com; location / { proxy_pass http://localhost:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } }

考虑禁用外部访问端口8080:

/sbin/iptables -A input -p tcp -i eth0 --dport 8080 -j REJECT --reject-with tcp-reset

示例Jetty配置( jetty.xml )可能类似于:

<?xml version="1.0" enCoding="utf-8"?> <!DOCTYPE Configure PUBliC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> <!-- | http://eclipse.org/jetty/documentation/current/configuring-connectors.HTML +--> <Configure ID="server" > <New ID="httpConfig" > <Set name="secureScheme">https</Set> <Set name="securePort"><Property name="jetty.tls.port" default="8443" /></Set> <Set name="outputBufferSize">65536</Set> <Set name="requestheaderSize">8192</Set> <Set name="responseheaderSize">8192</Set> </New> <Call name="addConnector"> <Arg> <New > <Arg name="server"><Ref refID="server" /></Arg> <Arg name="acceptors" type="int"><Property name="http.acceptors" default="-1"/></Arg> <Arg name="selectors" type="int"><Property name="http.selectors" default="-1"/></Arg> <Arg name="factorIEs"> <Array type="org.eclipse.jetty.server.ConnectionFactory"> <Item> <New > <Arg name="config"><Ref refID="httpConfig" /></Arg> </New> </Item> </Array> </Arg> <Set name="host"><Property name="jetty.host" default="localhost" /></Set> <Set name="port"><Property name="jetty.port" default="8080" /></Set> </New> </Arg> </Call> </Configure>

这将导致Jetty在localhost:8080和Nginx上侦听将来自domain.com:80的请求重定向到Jetty服务器。

总结

以上是内存溢出为你收集整理的如何configurationnginx作为代理到docker?全部内容,希望文章能够帮你解决如何configurationnginx作为代理到docker?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1278947.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存