This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
nginx [2018/10/24 12:04] jordan [Nginx配置Host以便响应服务器获取跳转前的地址] |
nginx [2023/03/08 16:09] (current) xujianglong ↷ Page moved from 内部资料:nginx to nginx |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | # Nginx 配置gzip加速网页加载速度 | + | ====== |
- | 参考[How To Add the gzip Module to Nginx on Ubuntu 14.04](https:// | + | 参考[[https:// |
- | # Nginx配置ssl证书 | + | ====== |
- | 参考[How To Secure Nginx with Let's Encrypt on Ubuntu 16.04](https:// | + | 参考[[https:// |
- | # Nginx配置Host以便响应服务器获取跳转前的地址 | + | [[https:// |
+ | |||
+ | ===== Nginx配置ssl证书报错解决方案 ===== | ||
+ | |||
+ | [[https:// | ||
+ | ====== | ||
场景:服务器端需要拿到浏览器中的url,但是这个url经过了nginx转发,默认拿到的是转发后的url,如果需要拿到之前的url,就需要配置proxy_set_header | 场景:服务器端需要拿到浏览器中的url,但是这个url经过了nginx转发,默认拿到的是转发后的url,如果需要拿到之前的url,就需要配置proxy_set_header | ||
- | ```bash | + | < |
location / { | location / { | ||
proxy_pass http:// | proxy_pass http:// | ||
Line 17: | Line 22: | ||
# ... | # ... | ||
} | } | ||
- | ``` | + | </ |
+ | |||
+ | |||
+ | ====== Nginx域名解析(反向代理) ====== | ||
+ | |||
+ | 以Ubuntu为例,编辑/ | ||
+ | |||
+ | <code bash> | ||
+ | server { | ||
+ | listen | ||
+ | server_name | ||
+ | error_log / | ||
+ | |||
+ | add_header Cache-Control public; | ||
+ | |||
+ | location / { | ||
+ | proxy_pass | ||
+ | proxy_redirect off; | ||
+ | |||
+ | proxy_set_header X-Real-IP $remote_addr; | ||
+ | proxy_set_header X-Forwarded-Host $host; | ||
+ | proxy_set_header X-Forwarded-Server $host; | ||
+ | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
+ | proxy_set_header X-Forwarded-Proto $scheme; | ||
+ | # 转发host信息 | ||
+ | proxy_set_header Host $host; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | **如果域名映射地址是wordpress,可能会出现跳转后的地址包含端口的情况,到wordpress管理端中修改url配置即可。** |