问题标签 [nginx-config]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
190 浏览

css - Serve .min.css files first nginx

I need to configure nginx server. I have folder with css files there are files some_file.min.css but in html website ask for some_file.css. I need to redirect this request to *min.css and if minified file doesnt exist return normal .css file

This piece of code does not work.

0 投票
2 回答
2814 浏览

ssl - 如何禁用 ssl 证书并仅用于转发 Nginx 中端口 443 上的流量?

Host A 有 https 服务serviceA并提供两个 IP 用于高可用。</p>

例如 Bose [ip1:443] 和 [ip2:443] 被路由到serviceA

主机 B(没有 ssl_certificate 和 ssl_certificate_key)使用 Nginx 代理模块将请求代理到实际的serviceA。如何在没有ssl验证的情况下简单地将443端口流量转发到serviceA ?这是我的配置:

0 投票
1 回答
1080 浏览

amazon-elastic-beanstalk - 如何在 AWS Beanstalk 环境中覆盖 nginx

有很多情况我们需要在 AWS beanstalk 环境中覆盖 nginx conf。

  • 设置最大文件附件
  • 强制 http 到 https
  • 为不同的静态资源设置不同的缓存过期时间
  • 设置 WebSocket
  • gzip 文件类型
  • 等等等等

AWS Support 建议使用 nginx.conf,它是 beanstalk 应用程序的副本,方法是查看实例中的 /etc/nginx/nginx.conf。这将用作基础,然后添加新的配置或块。然后在项目中使用 .ebextensions/nginx/nginx.conf 和这个内容。但是,最大的问题是,如果基础 nginx.conf 被 AWS 更改,那么可能很难首先知道它何时更改,然后重复复制它然后添加覆盖的步骤。像这样的东西

大多数网络搜索提供的其他选项是使用 container_commands 并在 appdeploy 或 configdeploy 中创建文件 在 container_commands 中,人们建议修改 /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf 类似这样的东西

这种方法的问题在于它仅在部署应用程序时才有效,而不是在任何 beanstalk 配置发生更改时(例如更改 env var)。

我的问题是覆盖 nginx 配置的更好的推荐方式。

0 投票
1 回答
610 浏览

nginx - Nginx 内部调用另一个请求并返回该请求数据

我正在使用 nginx 和 lua 来解析我的 rest api ( https://openresty-reference.readthedocs.io/en/latest/Lua_Nginx_API/ )。我试图在我的 rest 调用中内部调用另一个 api,它是一个不同的服务器并返回该响应。但它总是得到空洞的回应。以下是我的配置,我请求 /student 任何帮助都是非常可观的

0 投票
1 回答
1573 浏览

nginx - nginx:在没有 Host: 标头的情况下如何获取服务器?

对于在主机标头 ( ) 中使用 IP 地址的人,我有一个特殊的 server {} 块,server_name ~^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+;并且工作正常。当根本没有提供主机标头时,我想要一个不同的服务器块。我一直在测试:

我从我的日志记录("$http_host"在 log_format 中)看到这显示为"-"(连字符而不是下划线)。但是这个服务器块:

永远不会被使用,请求改为默认server_name _;(下划线不是连字符)。

我的用例类似于域停放站点,我希望处理大量主机名,并且应该在数据库中查找所有合法的主机名,但我想尽早筛选某些非法主机名。

0 投票
0 回答
24 浏览

node.js - 如何让 NGINX 接受 http://npomf/ 作为 proxy_pass?

我正在尝试在我的 vps 上设置Npomf,并且在执行设置说明时遇到此错误。我在我的配置 (hastebin)的第 61 行收到一个错误。我似乎无法解决这个proxy_pass问题,但其他一切正常。另外,我正在使用 NGINX 1.14.0

0 投票
1 回答
98 浏览

nginx - 尚不支持 SecContentInjection

使用 ContentInjection 规则时出现以下错误

vi /etc/nginx/nginx.conf nginx -s reload 10:26:25 [notice] 118#118: ModSecurity-nginx v1.0.0 10:26:25 [emerg] 118#118: "modsecurity_rules" 指令规则错误。文件:<>。行:1。列:16。尚不支持 SecContentInjection。在 /etc/nginx/nginx

rg]“modsecurity_rules”指令规则错误。文件:<>。行:1。列:16。尚不支持 SecContentInjection。在 /etc/nginx/nginx.conf:66

0 投票
1 回答
33 浏览

ssl - NGINX 配置不会将非 www 重定向到 www

我有一个 NodeJS 应用程序在 AWS EC2 实例上托管的 Ubuntu 16 服务器上的端口 3000 上运行。我希望 NGINX 将以下每个地址重定向到https://www.example.com

  1. http://example.com
  2. http://www.example.com
  3. https://example.com

为此,我将我的/etc/nginx/sites-available/default文件配置如下:

但是,这似乎只是部分起作用:

  1. http://example.com-> 去https://example.com而不是https://www.example.com
  2. http://www.example.com-> 去https://example.com而不是https://www.example.com
  3. https://example.com-> 去https://example.com而不是https://www.example.com
  4. https://www.example.com-> 工作正常

有什么建议么?

0 投票
1 回答
102 浏览

nginx - 如果在配置中指定了特定的 query_string,Nginx 会更改根目录

query_string如果配置中给出了具体的,我想更改根目录,

如果我点击 url http://www.test.com/?abc,那么它应该将 root 指向这个目录/var/data/www/abc,如果我点击这个 url , http://www.test.com/def?root 应该是/var/data/www/def,如果没有query_string通过,那么 root dir/var/data/www实际上应该指向没有query_string条件。

知道我该怎么做吗?

0 投票
1 回答
32 浏览

nginx - nginx 重写不起作用 - 返回 404

我正在尝试重写:

http://example/test/ -> http://example/new/

http://example/test/check -> http://example/new/check

我究竟做错了什么?