嘟嘟社区

nginx反代问题求解


本帖最后由 pulpfunction 于 2022-6-12 18:19 编辑

plex反代问题:

环境:lnmp 单装nginx,宝塔弃用

思路 :https://hostloc.com/thread-930261-1-1.html   照图里设置了,可能nginx哪里没设置对

现在解码服务器用ip不加端口能访问plex
但是中转服务器(线路较好)域名访问就是lnmp首页(安装教程此处应该看到plex后台),此时f12看到也是本鸡ip地址

二楼三楼贴俩nginx.conf
xxx.domin.com 为域名

弄好写个保姆级教程

妈蛋 域名访问没问题了,现在后台一堆本地回环请求

plex解码鸡:
  1. user  www www;
  2. worker_processes auto;
  3. worker_cpu_affinity auto;
  4. error_log  /home/wwwlogs/nginx_error.log  crit;
  5. pid        /usr/local/nginx/logs/nginx.pid;
  6. #Specifies the value for maximum file descriptors that can be opened by this process.
  7. worker_rlimit_nofile 51200;
  8. events
  9.     {
  10.         use epoll;
  11.         worker_connections 51200;
  12.         multi_accept off;
  13.         accept_mutex off;
  14.     }
  15. http
  16.     {
  17.         include       mime.types;
  18.         default_type  application/octet-stream;
  19.         server_names_hash_bucket_size 128;
  20.         client_header_buffer_size 32k;
  21.         large_client_header_buffers 4 32k;
  22.         client_max_body_size 5000m;
  23.         proxy_set_header X-Real-IP $remote_addr;
  24.         proxy_set_header X-Forwarded-For ‘$proxy_add_x_forwarded_for’;
  25.         proxy_set_header X-Forwarded-Proto $scheme;
  26.         proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
  27.         proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
  28.         proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
  29.         proxy_cache off;
  30.         proxy_redirect off;
  31.         proxy_buffering off;
  32.         sendfile on;
  33.         sendfile_max_chunk 512k;
  34.         tcp_nopush on;
  35.         keepalive_timeout 60;
  36.         tcp_nodelay on;
  37.         fastcgi_connect_timeout 300;
  38.         fastcgi_send_timeout 300;
  39.         fastcgi_read_timeout 300;
  40.         fastcgi_buffer_size 64k;
  41.         fastcgi_buffers 4 64k;
  42.         fastcgi_busy_buffers_size 128k;
  43.         fastcgi_temp_file_write_size 256k;
  44.         gzip on;
  45.         gzip_min_length  1k;
  46.         gzip_buffers     4 16k;
  47.         gzip_http_version 1.1;
  48.         gzip_comp_level 2;
  49.         gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
  50.         gzip_vary on;
  51.         gzip_proxied   expired no-cache no-store private auth;
  52.         gzip_disable   "MSIE [1-6].";
  53.         #limit_conn_zone $binary_remote_addr zone=perip:10m;
  54.         ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
  55.         server_tokens off;
  56.         access_log off;
  57. server
  58.     {
  59.         listen 80 default_server reuseport;
  60.         #listen [::]:80 default_server ipv6only=on;
  61.         server_name _  xxx.domin.com;
  62.         index index.html index.htm index.php;
  63.         root  /home/wwwroot/default;
  64.         #error_page   404   /404.html;
  65.         # Deny access to PHP files in specific directory
  66.         #location ~ /(wp-content|uploads|wp-includes|images)/.*.php$ { deny all; }
  67.         include enable-php.conf;
  68.         location /nginx_status
  69.         {
  70.             stub_status on;
  71.             access_log   off;
  72.         }
  73.         
  74.         location / {
  75.             proxy_pass http://127.0.0.1:32400/;
  76.             proxy_set_header X-Forwarded-For $remote_addr;
  77.             proxy_ssl_verify off;
  78.             proxy_http_version 1.1;
  79.             proxy_set_header Host $http_host;
  80.             proxy_set_header Upgrade $http_upgrade;
  81.             proxy_set_header Connection "upgrade";
  82.             proxy_read_timeout 86400;
  83.         }       
  84.         
  85.                
  86.        
  87.         location ~ /.
  88.         {
  89.             deny all;
  90.         }
  91.         access_log  /home/wwwlogs/access.log;
  92.     }
  93. include vhost/*.conf;
  94. }

复制代码

中转鸡:
  1. user  www www;
  2. worker_processes auto;
  3. worker_cpu_affinity auto;
  4. error_log  /home/wwwlogs/nginx_error.log  crit;
  5. pid        /usr/local/nginx/logs/nginx.pid;
  6. #Specifies the value for maximum file descriptors that can be opened by this process.
  7. worker_rlimit_nofile 51200;
  8. events
  9.     {
  10.         use epoll;
  11.         worker_connections 51200;
  12.         multi_accept off;
  13.         accept_mutex off;
  14.     }
  15. http
  16.     {
  17.         include       mime.types;
  18.         default_type  application/octet-stream;
  19.         server_names_hash_bucket_size 128;
  20.         client_header_buffer_size 32k;
  21.         large_client_header_buffers 4 32k;
  22.         client_max_body_size 50m;
  23.         sendfile on;
  24.         sendfile_max_chunk 512k;
  25.         tcp_nopush on;
  26.         keepalive_timeout 60;
  27.         tcp_nodelay on;
  28.         fastcgi_connect_timeout 300;
  29.         fastcgi_send_timeout 300;
  30.         fastcgi_read_timeout 300;
  31.         fastcgi_buffer_size 64k;
  32.         fastcgi_buffers 4 64k;
  33.         fastcgi_busy_buffers_size 128k;
  34.         fastcgi_temp_file_write_size 256k;
  35.         gzip on;
  36.         gzip_min_length  1k;
  37.         gzip_buffers     4 16k;
  38.         gzip_http_version 1.1;
  39.         gzip_comp_level 2;
  40.         gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
  41.         gzip_vary on;
  42.         gzip_proxied   expired no-cache no-store private auth;
  43.         gzip_disable   "MSIE [1-6].";
  44.         #limit_conn_zone $binary_remote_addr zone=perip:10m;
  45.         ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
  46.         server_tokens off;
  47.         access_log off;
  48. server
  49.     {
  50.         listen 80 default_server reuseport;
  51.         #listen [::]:80 default_server ipv6only=on;
  52.         server_name _  xxx.domin.com;
  53.         index index.html index.htm index.php;
  54.         root  /home/wwwroot/default;
  55.         #error_page   404   /404.html;
  56.         # Deny access to PHP files in specific directory
  57.         #location ~ /(wp-content|uploads|wp-includes|images)/.*.php$ { deny all; }
  58.         include enable-php.conf;
  59.         location /nginx_status
  60.         {
  61.             stub_status on;
  62.             access_log   off;
  63.         }
  64.         location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
  65.         {
  66.             expires      30d;
  67.         }
  68.         location ~ .*.(js|css)?$
  69.         {
  70.             expires      12h;
  71.         }
  72.         location ~ /.well-known {
  73.             allow all;
  74.         }
  75.         location ~ /.
  76.         {
  77.             deny all;
  78.         }
  79.         access_log  /home/wwwlogs/access.log;
  80.     }
  81. include vhost/*.conf;
  82. }

复制代码