nginx -V 输出
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
Run Code Online (Sandbox Code Playgroud)
NGINX 配置
upstream websocknodes{
server 192.168.1.2:7070;
}
location /mywebsocket/server {
proxy_pass http://192.168.1.2:7070/mywebsocket/server;
tcp_nodelay on;
proxy_redirect off;
proxy_next_upstream error timeout;
proxy_connect_timeout 2;
proxy_read_timeout 300s; …Run Code Online (Sandbox Code Playgroud) 我有一个 jenkins 构建器服务器,我正在尝试使用 nginx 设置反向代理。我遵循了 jenkins 站点上的所有操作方法和文档,但唯一不同的是我需要可以在不同端口上访问服务器,然后是标准 https 端口。
必须可以访问https://jenkins.example.com:9090现在正在运行的服务器,但我仍然遇到一些问题。在管理詹金斯我不断收到消息
您的反向代理设置似乎已损坏
此外,当我登录或应用或保存一些配置更改时,我不断被重定向到https://jenkins.example.com没有端口号。
当我检查 curl 并查看某些页面的标题时,它会不断将位置标题设置为正确的 url 但没有端口号。
我在nginx中有以下配置
server {
listen 443 ssl spdy;
server_name jenkins.example.com;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-Frame-Options "DENY";
ssl on;
ssl_certificate /etc/nginx/ssl/server.chain.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-$
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
# enable ocsp stapling (mechanism by which a site can convey certificate revocation information to …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Nginx 作为我在 github 页面上的页面的反向代理。根据此处的信息:https : //pascal.io/github-pages-https/和其他人,我的配置如下所示:
server {
listen 80 default_server;
server_name leepope.com www.leepope.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name leepope.com;
ssl on;
ssl_certificate <my cert>;
ssl_certificate_key <my key>;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:10m;
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security max-age=15768000;
location / {
proxy_pass https://leepope.github.io;
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_intercept_errors on;
expires off;
}
}
Run Code Online (Sandbox Code Playgroud)
当我向服务器根目录发出请求时,我得到了一个 github 页面,但它是 404。
我已经启用了 nginx 调试,但是我看不到发送到 github …
问题:Nginx 和 Netty 用于构建代理服务器的优缺点是什么?
细化问题:
我们正在尝试实现一个代理服务器(正向或反向代理),它位于服务前面,并负责可应用于我们服务的良好实践。
因此,我们正在评估市场上可用的不同解决方案,主要是 Nginx 和 Netty。因此,当我们最初对 Nginx 进行研究时,我们遇到了大量正面的博客,这些博客表明 Nginx 非常快,通过编写自定义模块到 Nginx 插件可以轻松配置。
但是当我们在 Netty 上做 POC 时,我们在使用 Netty 4 时得到了更好的性能数据。 所以我想知道是否有人对 Nginx 和 Netty 进行了一些比较,以及不使用 Netty 作为反向的原因是什么/转发代理解决方案。我们担心与 Java Server 解决方案相关的 GC 问题,因此我们想在继续解决方案之前了解 Nginx 和 Netty 的优缺点。
谢谢,维奈。
我有 5 个后端服务器。我希望 nginx 将 /myapp/refresh 的 POST 请求转发到所有 5 个后端服务器。对于任何其他请求,它可以做负载平衡。这可能吗 ?你能给出一个示例配置吗?
我正在使用 Nginx 反向代理,因此当访问者查看 example.com 时,他们实际上正在查看 example.com:8888。以前它工作正常,但今天早上突然无法通过域访问,但仍然可以使用端口 8888 的 IP 地址访问。
所以我怀疑这个问题是由 Nginx 引起的,当我查看日志时,我发现多行显示upstream timed out错误,我发现上游 IP 地址是 Cloudflare 的 IP(我将我的域指向 Cloudflare)。
我不确定为什么它突然不能再访问了。任何人都可以提供帮助?谢谢。这是错误日志:
2017/07/17 07:53:41 [error] 25707#25707: *31 no live upstreams while connecting to upstream, client: [MY IP], server: www.example.com$, request: "GET / HTTP/1.1", upstream: "http://www.example.com/", host: "www.example.com"
2017/07/17 07:53:41 [error] 25707#25707: *33 upstream timed out (110: Connection timed out) while connecting to upstream, client: [MY IP], server: www.example.com$, request: "GET / HTTP/1.1", upstream: "http://104.18.51.97:8888/", host: "www.example.com"
Run Code Online (Sandbox Code Playgroud)
这是 Nginx …
我已经阅读了文档,但我无法弄清楚如何配置 Traefik v2 以在不涉及 Docker 的情况下将 Nginx 替换为网站(虚拟主机)的反向代理。理想情况下,我们也会加密 https。
我有一个在http://127.0.0.1:4000运行的服务,我想从http://myhost.com:80反向代理
这是我到目前为止提出的配置:
[Global]
checkNewVersion = true
[log]
level = "DEBUG"
filePath = "log-file.log"
[accessLog]
filePath = "log-access.log"
bufferingSize = 100
[entrypoints]
[entrypoints.http]
address = ":80"
[http]
[http.routers]
[http.routers.my-router]
rule = "Host(`www.myhost.com`)"
service = "http"
entrypoint=["http"]
[http.services]
[http.services.http.loadbalancer]
[[http.services.http.loadbalancer.servers]]
url = "http://127.0.0.1:4000"Run Code Online (Sandbox Code Playgroud)
我正在运行 Caddy v1 作为反向代理,并且我想对例如 JSON 响应应用 GZIP 压缩。
我注意到gzipCaddy v1 指令仅适用于 Caddy 为其自身服务的文件,而不适用于 Caddy 使用该proxy指令运行反向代理的响应。
0.0.0.0:8080 {
gzip {
ext *
level 9
}
log stdout
errors stdout
proxy /api/v2 127.0.0.1:50010 {
transparent
without /api/v2
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法压缩代理的响应主体,或者 Caddy 无法做到这一点?
文件:
# main.py:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
Run Code Online (Sandbox Code Playgroud)
——
# nginx.conf:
events {
worker_connections 128;
}
http{
server {
listen 0.0.0.0:8080;
location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/uvi.sock;
}
}
}
Run Code Online (Sandbox Code Playgroud)
——
# Dockerfile
FROM python:3
COPY main.py .
RUN apt-get -y update && apt-get install -y htop tmux vim nginx
RUN pip install fastapi uvicorn
COPY nginx.conf /etc/nginx/
Run Code Online (Sandbox Code Playgroud)
设置:
docker build -t nginx-uvicorn:latest .
docker run -it --entrypoint=/bin/bash --name …Run Code Online (Sandbox Code Playgroud) 我的服务器上有 3 个不同的 docker 容器在端口上运行 -
我想配置我的服务器,以便每当请求命中以下路径时,它应该被重定向到相关容器 -
我已经完成将 /container1 重定向到 localhost:5000。但是,它不提供容器 1 中托管的任何静态文件
我的 nginx.conf 文件 -
#user nobody;
worker_processes 1;
http {
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /container1/ {
proxy_pass http://127.0.0.1:5000;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html; …Run Code Online (Sandbox Code Playgroud) reverse-proxy ×10
nginx ×8
android ×1
build-server ×1
caddy ×1
caddyfile ×1
cloudflare ×1
curl ×1
docker ×1
fastapi ×1
github-pages ×1
gzip ×1
jenkins ×1
netty ×1
node.js ×1
performance ×1
proxy ×1
python ×1
traefik ×1
ubuntu ×1
uvicorn ×1
websocket ×1