小编Iva*_*sky的帖子

如何使用反向代理在 Nginx 中处理应用程序级别重定向

我正在为基于 Crystal-Lang 的应用程序编写 Nginx 配置,以通过反向代理http://example.com/videos/发送所有流量。http://0.0.0.0:3000

我已经编写了以下配置,该配置不起作用,我正在互联网上但没有运气。

当我转到 时,应用程序在内部执行从问题所在的http://example.com/videos/重定向,它重定向到错误的位置,我需要像往常一样始终将部分与 URL 连接起来,但在重定向后,该部分将被切掉。所以应用程序应该考虑作为主机。http://example.com/http://example.com/feed/popularhttp://example.com/feed/popular/videos/http://example.com/videos/xxxx/videos/http://example.com/videos/

这是我的配置:

server {
    listen 80;
    server_name elearn.com.pk default_server localhost;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    location /videos/ {
        proxy_pass http://0.0.0.0:3000/;
        proxy_http_version 1.1;
        rewrite /videos/(.*) /$1 break;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host/videos/;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
   }
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?谢谢。

nginx crystal-lang alpine-linux

6
推荐指数
1
解决办法
3724
查看次数

Angular CLI - ng 服务 --serve-path

我正在尝试使用 --serve-path 在该路径下为我的整个应用程序提供服务。例如,我希望我的路径是localhost:4200/foobar我使用的ng serve --serve-path=/foobar/。然后,当我转到该网址时,我的应用程序不会加载,并且出现空白屏幕。

angular-cli

5
推荐指数
1
解决办法
1万
查看次数

如何克隆全局 WP_Query 对象并仅更改一个参数?

我在我的 WordPress 安装中添加了一个新的post_type帖子,我想查询这些帖子并循环使用它们。问题是我必须手动构建参数,具体取决于它是类别页面还是标签页面等。

有没有办法重用已经可用的全局 WP_Query 对象,修改参数post_type并运行查询?

这就是我想避免的:

$query = array(
  'post_type' => 'vehicle',
);

if( is_category() ){
  $query['category_name'] = get_query_var('category_name')
}

if( is_category() ){
  $query['category_name'] = get_query_var('category_name')
}

if( is_tag() ){
  $query['tag'] = get_query_var('tag')
}


// ... and so on

$loop = new WP_Query($query);
Run Code Online (Sandbox Code Playgroud)

我不想使用该pre_get_posts方法,因为这样做会改变用于网站其余部分的全局查询。

php wordpress

3
推荐指数
1
解决办法
1852
查看次数

nginx配置文件:server、server_name和upstream的理解

我有一个从 github 项目继承的 nginx.conf 配置文件,我希望有人能解释一下我在做什么:

upstream hello_django {
    server web:8000;
}

server {
    listen 80;
    server_name react-wagtail-api.accordbox.com;
    location / {
        proxy_pass http://hello_django;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        client_max_body_size 20M;
    }
    location /static/ {
        alias /app/static/;
    }
    location /media/ {
        alias /app/media/;
    }
}

server {
    listen 80;
    server_name react-wagtail.accordbox.com;
    location / {
      root   /usr/share/nginx/html/build;
      index  index.html index.htm;
      try_files $uri $uri/ /index.html;
    }
}
Run Code Online (Sandbox Code Playgroud)

upstream hello_django {
        server web:8000;
    }
Run Code Online (Sandbox Code Playgroud)

web一个服务(其他地方有一个 docker-compose 容器名称,它是web......它是对此的引用吗?)?具体定义是什么 …

nginx nginx-config

2
推荐指数
1
解决办法
1万
查看次数