Articles of nginx

NGINXredirect多个域名

我对NGINX和整个configuration都很陌生,所以我在一位朋友的帮助下,设法用下面的configuration设置了服务器: server { listen 80; listen [::]:80; server_name domain.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 80; listen [::]:80; server_name domain.de; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name domain.com domain.de; root /var/www/html; index index.php index.html index.htm; 有多个服务器为我的主页面,一些项目页面和一些私人页面。 我为每个TLD都有一台自己的服务器,因为我不希望地址栏中的TLD在redirect时发生变化。 现在我的答案是,如何将所有这些非SSL服务器简单地转换为一个大型服务器(1 /项目)而不重​​定向到一个TLD? 例: Project.com,Project.de,Project.net和Project.org将其中5个以上的非SSL服务器redirect到一个启用了SSL的服务器。 当我要去http://project.net我beeingredirect到https://project.net 。 由于单一的非SSL服务器设置,TLD根本不会改变。 […]

在Nginx中的类似Apache的目录列表回退

我已经从Apache切换到nginx了,我发现一个方便的东西是能够把一个'index.html'文件放在一个目录中,并且被提供,但是如果没有这样的文件存在,Apache会生成一个目录列表。 我已经能够得到nginx做目录列表,但它忽略了index.html文件。 有没有人能够实现这一行为?

如何处理到web服务器的IP请求

例如:我使用Nginx在Ubuntu Server(10.20.30.40)上托pipe了4个网站。 现在,当有人打开浏览器并input我的服务器的IP时,我该如何处理这种请求。 什么pipe理员主要用这个? 我知道普通用户永远不会inputIP。

Nginx允许PHP文件仅用于某些IP

我正在使用下面的指令来阻止几个文件types的执行 location ~* (\.php$|\.htaccess$|\.git) { deny all; } 我怎样才能允许一个特定的IP地址执行一个PHP脚本? 我尝试了以下来允许执行一个PHP脚本,但不工作.. location ~ ^adminer.php { fastcgi_pass php-fpm:9000; fastcgi_index adminer.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log"; include fastcgi_params; }

Nginx的HTTP到HTTPSredirect不起作用

我正在运行一个Redmine实例,它使用nginx的SSL和apache来提供内容。 我正在通过在新机器上安装最新版本来升级这个版本,一旦完成所有工作,我将复制文件和数据库。 我已经从现有的机器上复制了Apache和Nginx的configuration到新的机器,但结果是不同的两台机器,我不明白为什么。 在目前的生产实例中,Redmine正在18804港口运行(如我的老板所定)。 目前,当有人使用浏览器访问redmine.mydomain.com时,他们会自动使用HTTPSredirect到Redmine。 发生这种情况的原因是:18804是否被追加到末尾,这是我希望如何操作的。 但是,在新机器上,如果在浏览器中inputnewredmine.mydomain.com,我将被redirect到nginxtesting页面。 但是,如果我inputnewredmine.mydomain.com:18804或https://newredmine.mydomain.com ,那么我将使用HTTP路由到应用程序。 我只需input逻辑URL即可完成此操作。 很明显,redirect到HTTPS不工作,但作为configuration是一个确切的副本,我不明白为什么。 当前服务器正在运行Amazon Linux,Apache 2.2.31和nginx 1.10.2。 新的运行Centos 7,Apache 2.4.6和nginx 1.10.2。 这是我的应用程序的configurationnginx: upstream redmine { server 127.0.0.1:18805; } server { listen 18804; location / { return 301 https://$host$request_uri; } } server { listen 80; location / { return 301 https://$host$request_uri; } } server { listen 443 ssl; […]

Apache2使用疯狂的内存量

在具有30GB内存的服务器上,服务器的stream量较高。 出于某种原因,最近Apache2已经开始运行疯狂的内存使用线程。 每线程500MB-750MB现在并不less见。 php.ini有memory_limit = 128M (默认是php7.0)。 Apache preforkconfiguration是默认值。 结果就是我们只能运行〜1GB的空闲内存。 我错过了什么? 我们有Nginx的代理请求,它的进程更像每个线程约60MB。 这里是运行top的截图 热门截图 任何洞察到什么可能是驾驶这个赞赏!

Nginx将根转发给一个地址,其余的转发给其他地址

我有我的nginxconfiguration这个代理传递。 location /content { proxy_set_header Host $proxy_host; proxy_pass $address1; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } if ($request_method = 'POST') { add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; } if ($request_method = 'GET') { add_header […]

将httpredirect到https但排除一些

我正在使用nginx,我想知道是否有可能做到这一点。 现在要pipe理我的虚拟主机,我分别在/ etc / nginx / sites-available(在之后激活它们) mydomain.com subdomain.mydomain.com subdomain1.mydomain.com anotherdomain.com 所以要将httpredirect到https,我创build了一个redirect虚拟主机,其中包含: server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 301 https://$host$request_uri; } mydomain.com和所有其他子域都在https下。 但问题是anotherdomain.com,我不想redirect到https。 在这里,我不知道该怎么做。 我有一个主意 : 仅在包含所有configuration的虚拟主机上创build,然后执行以下操作: # Config of anotherdomain.com # Redirect all domain/subdomain after this part to https server { listen 80 default_server; listen [::]:80 default_server; server_name _; […]

如何将nginx.conf文件直接放在网站的根目录下?

我经历了一个WordPress插件做到这一点,我不知道这是可能的。 这个插件告诉我它在nginx.conf中做了一些修改,但是我不明白它是如何做到的,因为它没有权限在/ etc / nginx文件夹中这样做。 我查了一下,看到它已经在网站的www根文件夹中直接创build了一个nginx.conf文件。 nginx放置在网站的根目录下时是否自动包含文件?

在Nginx SSL终止中将所有无效的SSL请求redirect到http

在我的后端服务器作为反向代理之前,我使用nginx进行SSL终止。 我想redirect所有无效的https域(不是SSL),redirect到Nginx的SSL终止http。 我不想为所有网站做这个单独的每一个,我想要一个通用的解决scheme,所有的请求没有HTTPS,但打开与HTTPS和redirect到HTTP自动。 我有nginx的SSL终止。 谢谢