VPS侦探论坛

 找回密码
 注册
查看: 2457|回复: 7

请问军哥现在LNMP1.9的反向代理的配置文件应该怎么设置

[复制链接]
发表于 2022-10-21 22:34:31 | 显示全部楼层 |阅读模式

请问军哥现在的反向代理的配置文件应该怎么设置

LNMP1.9

虚拟主机的配置文件内容为

Le_Domain='www.123.com'
Le_Alt='123.com'
Le_Webroot='/home/wwwroot/www.123.com'
Le_PreHook=''
Le_PostHook=''
Le_RenewHook=''
Le_API='https://acme-v02.api.letsencrypt.org/directory'
Le_Keylength=''
Le_OrderFinalize='https://acme-v02.api.letsencrypt.org/acme/finalize/787846876/136624562666'
Le_LinkOrder='https://acme-v02.api.letsencrypt.org/acme/order/787846876/136624562666'
Le_LinkCert='https://acme-v02.api.letsencrypt.org/acme/cert/0378e4571f6e92b69e84feaa9c496b538f28'
Le_CertCreateTime='1666361890'
Le_CertCreateTimeStr='Fri 21 Oct 2022 02:18:10 PM UTC'
Le_NextRenewTimeStr='Tue 20 Dec 2022 02:18:10 PM UTC'
Le_NextRenewTime='1671459490'
Le_RealCertPath=''
Le_RealCACertPath=''
Le_RealKeyPath=''
Le_ReloadCmd='__ACM                                                                                                                                                                                                                                                                                                                                                            E_BASE64__START_L2V0Yy9pbml0LmQvbmdpbnggcmVsb2Fk__ACME_BASE64__END_'
Le_RealFullChainPath=''


美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2022-10-22 14:10:18 | 显示全部楼层


你这是acme.sh的域名续费配置文件不是虚拟主机配置文件
如果要设置反向代理,lnmp安装包conf/example/ 下已经都有反向代理的例子了
另外ssl续期还要按官网301里面的教程添加上.well-known的location
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2022-11-5 20:30:03 | 显示全部楼层

licess 发表于 2022-10-22 14:10
你这是acme.sh的域名续费配置文件不是虚拟主机配置文件
如果要设置反向代理,lnmp安装包conf/example/ 下已 ...

军哥请教下,我用的是二级域名,根据nginx-reverse-proxy-example.conf修改

server {
        listen 80;
        server_name 二级域名 ;
        return 301 https://$host$request_uri;

       }

server {
        listen 443 ssl http2;
        server_name 二级域名;

        ssl_certificate /usr/local/nginx/conf/ssl/二级域名/fullchain.cer;
        ssl_certificate_key /usr/local/nginx/conf/ssl/二级域名/bwg.xxvps.xyz.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

        location / {
            proxy_pass https://被代理的站点域名/;
            proxy_http_version    1.1;
            proxy_cache_bypass    $http_upgrade;
            proxy_set_header Upgrade            $http_upgrade;
            proxy_set_header Connection         "upgrade";
            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_set_header X-Forwarded-Proto  $scheme;
            proxy_set_header X-Forwarded-Host   $host;
            proxy_set_header X-Forwarded-Port   $server_port;
        }

        access_log /home/wwwlogs/二级域名.log;
}

修改后
测试Nginx配置文件语法
nginx -t
没有报错
重新加载Nginx
systemctl reload nginx

但是还是不能正常生效,我这个虚拟主机的配置文件哪里设置的不正确
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2022-11-6 15:31:31 | 显示全部楼层



nginx -s reload 或重启nginx试一下
另外你说的未生效具体什么错误信息
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2022-11-6 18:54:55 | 显示全部楼层

反代到 https://www.google.com/
返回的结果是
——————————————————
404. That’s an error.

The requested URL / was not found on this server. That’s all we know.
——————————————————
反代到 https://www.amazon.com/
返回的结果是
——————————————————
403 ERROR

The request could not be satisfied.

Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: XvcIXTA5LdYCcWyCRspb_In4OTDWw5e7nidocAJu1ns_R7eBfU3I_g==
——————————————————

反代到 同一IP地址下的另外一个域名上
返回的结果是
——————————————————
400 Bad Request

Request Header Or Cookie Too Large
nginx
——————————————————

军哥运维代购:http://shop63846532.taobao.com/

发表于 2022-11-7 08:38:27 | 显示全部楼层

很酷很拽的昵称 发表于 2022-11-6 18:54
反代到 https://www.google.com/
返回的结果是
——————————————————

被反代域名后面不要加斜杠
 楼主| 发表于 2022-11-7 19:01:51 | 显示全部楼层

licess 发表于 2022-11-7 08:38
被反代域名后面不要加斜杠

现在的返回的结果是
不管我反代什么域名,返回的结果就是这个
被反代的域名后面没有加 / 斜杠

403 ERROR
The request could not be satisfied.
Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: ve_PTm7wof94yfRt6ogqEjiq14b02DaIXu_n0xA27bHHob8hYSd1qw==
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2022-11-8 09:53:23 | 显示全部楼层

很酷很拽的昵称 发表于 2022-11-7 19:01
现在的返回的结果是
不管我反代什么域名,返回的结果就是这个
被反代的域名后面没有加 / 斜杠

403的提示应该是被cloudfront的waf拦截了吧
大站一般情况下不是一个简单的发代配置就能搞定的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-7-27 11:38 , Processed in 0.027476 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表