User Tools

Site Tools


nginx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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加速网页加载速度+====== Nginx 配置gzip加速网页加载速度 ======
  
-参考[How To Add the gzip Module to Nginx on Ubuntu 14.04](https://www.digitalocean.com/community/tutorials/how-to-add-the-gzip-module-to-nginx-on-ubuntu-14-04)+参考[[https://www.digitalocean.com/community/tutorials/how-to-add-the-gzip-module-to-nginx-on-ubuntu-14-04|How To Add the gzip Module to Nginx on Ubuntu 14.04]]
  
-Nginx配置ssl证书+====== Nginx配置ssl证书 ======
  
-参考[How To Secure Nginx with Let's Encrypt on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04)+参考[[https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04|How To Secure Nginx with Let's Encrypt on Ubuntu 16.04]]
  
-Nginx配置Host以便响应服务器获取跳转前的地址+[[https://www.trustasia.com/news-201801-nginx-server-certificate-deployment|Nginx配置百度云ssl证书教程]] 
 + 
 +===== Nginx配置ssl证书报错解决方案 ===== 
 + 
 +[[https://www.cnblogs.com/faithfu/p/12697762.html|SSL证书报错:X509_check_private_key:key values mismatch]] 
 +====== Nginx配置Host以便响应服务器获取跳转前的地址 ======
  
 场景:服务器端需要拿到浏览器中的url,但是这个url经过了nginx转发,默认拿到的是转发后的url,如果需要拿到之前的url,就需要配置proxy_set_header 场景:服务器端需要拿到浏览器中的url,但是这个url经过了nginx转发,默认拿到的是转发后的url,如果需要拿到之前的url,就需要配置proxy_set_header
  
-```bash+<code bash>
 location / { location / {
     proxy_pass http://my_app_upstream;     proxy_pass http://my_app_upstream;
Line 17: Line 22:
     # ...     # ...
 } }
-```+</code> 
 + 
 + 
 +====== Nginx域名解析(反向代理) ====== 
 + 
 +以Ubuntu为例,编辑/etc/nginx/conf.d/<site-name>.conf 
 + 
 +<code bash> 
 +server {                     
 +    listen       80;         
 +    server_name  www.codedemo.club; 
 +    error_log /mengyunzhi/log/baeldung.cn-nginx.log info; 
 +                             
 +    add_header Cache-Control public; 
 +                             
 +    location / {             
 +        proxy_pass      http://127.0.0.1:8000; 
 +        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; 
 +    } 
 +
 +</code> 
 + 
 +**如果域名映射地址是wordpress,可能会出现跳转后的地址包含端口的情况,到wordpress管理端中修改url配置即可。**
nginx.1540353858.txt.gz · Last modified: 2021/02/10 21:29 (external edit)