标签: nginx

在vultr上的Ubuntu服务器上成功设置nginx但在浏览器上看不到nginx欢迎页面

我已经一步步按照这篇文章(https://coderrocketfuel.com/article/how-to-set-up-nginx-on-a-ubuntu-server-with-vultr)在 Vultr 上设置一个实例以及所有内容进行得很顺利,但在第二步结束时,文章说“访问http://server_domain_or_IP”,你应该看到nginx欢迎页面,我转到http://my_server_ip_address,并且我总是得到“连接浏览器上出现“超时”屏幕。

ubuntu nginx vultr

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

Fedora fastcgi 上的 nginx 无法正常工作

我在 Fedora Server 22 上运行 nginx 并且 fastcgi 脚本不起作用。

http://panel.minefight.org/ 下输入任何登录数据,它不会加载密码失败或成功站点。其他登录表单也会发生同样的事情。服务器没有重定向用户,我不知道如何解决这个问题。我希望这个例子容易理解。

testpage 说,fastcgi 正在运行并与 nginx 连接。

php-fpm.conf

upstream php-fpm {
    server unix:/run/php-fpm/www.sock;
}
Run Code Online (Sandbox Code Playgroud)

php.conf

index index.php index.html index.htm;

location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
fastcgi_index  index.php;
include        fastcgi_params;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_pass   php-fpm;
}
Run Code Online (Sandbox Code Playgroud)

错误日志包含以下内容(尝试登录游戏面板时):

    2015/05/30 22:15:57 [error] 1911#0: *1 FastCGI sent in stderr: "PHP    message: PHP Deprecated:  mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli …
Run Code Online (Sandbox Code Playgroud)

php nginx fedora centos fastcgi

0
推荐指数
1
解决办法
5265
查看次数

PHP opcache。100% 命中,100% 使用内存

我的 PHP OPcache 达到 100% 内存使用率

General info
Zend OPcache    7.0.4-dev
PHP 5.5.23-1+deb.sury.org~trusty+2
Server Software nginx/1.6.2
Run Code Online (Sandbox Code Playgroud)

这是我的缓存设置:

zend_extension=opcache.so
opcache.memory_consumption=1024
opcache.max_accelerated_files=50000
opcache.revalidate_freq=180
opcache.consistency_checks=0
Run Code Online (Sandbox Code Playgroud)

还有一些关于缓存命中的更多信息:

total memory: 1024.000MB
used memory: 1010.398MB
free memory: 35.086KB
wasted memory: 13.568MB (1.32%)
number of cached files: 10,724
number of hits: 9,576,431
number of misses: 21,450
blacklist misses: 0
number of cached keys: 12,971
max cached keys: 65,407
Run Code Online (Sandbox Code Playgroud)

opcache 面板视图

我应该担心 100% 内存使用率吗?有人可以用外行术语解释 OPcache 内存使用吗?

服务器有 8GB 内存(Linode)

memory nginx cache php-fpm

0
推荐指数
1
解决办法
9729
查看次数

允许自定义域指向我的 saas 应用程序的服务器配置,只需将它们的名称服务器更改为我自己的

我已经成功构建了一个允许用户添加自定义域名的 saas 应用程序,我的问题是如何配置我的服务器以允许用户将他们的域名指向我的 saas 应用程序,只需将他们的域名服务器更改为我的 saas 应用程序名称服务器,例如。ns1.saasapp.com,ns2.saasapp.com 我的堆栈是 Nginx php 和 mysql。

nginx saas

0
推荐指数
1
解决办法
565
查看次数

nginx 如何拥有 try_files 的动态顺序

我不知道如何更好地表达这个问题,所以让我知道是否有更好的方法,但这是我想要做的。

我有一个应用程序,它根据请求 url 发送一个 html 文件,它还在缓存文件夹中创建该 html 文件的缓存,以便 nginx 可以在下次有人访问相同的 url 时提供缓存文件。

这是按预期工作的,除了我不希望在有查询参数时 nginx 读取缓存。我希望应用程序在发生这种情况时处理请求,但缓存被发送。这是我到目前为止所拥有的:

    location / {
        root    /path/to/site;
        try_files /content/cache/$uri.html @app;
    }

    location @app {
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080;
    }
Run Code Online (Sandbox Code Playgroud)

那么当 url 中有查询参数时,我如何try_files绕过content/cache/$uri.html并直接转到@app

nginx

0
推荐指数
1
解决办法
609
查看次数

我需要使用 arg 键重写 nginx 匹配位置

我将一个 URL 用于不同的目的:

  1. /path/items :返回项目列表
  2. /path/items?id=XXX :重定向到 URL /path/items/item?id=XXX

编辑:添加了基于 Tero 输入的解决方案

我在我的 nginx conf 文件中尝试过该规则:

location ~ / {
    rewrite '^/path/items\?id=([0-9]*)$' /items/item?id=$1? break;
}
Run Code Online (Sandbox Code Playgroud)

当我访问页面 /path/items?id=XXX 时,我得到以下日志:

2016/08/25 14:08:53 [通知] 22903#0: 1 "^/path/items\?id=([0-9] )$" 与 "/path/items" 不匹配,客户端:XXX ,服务器:local.xxx.ins,请求:“GET /path/items?id=32442305 HTTP/1.1”,主机:“local.xxx.ins”

我从该日志中了解到 nginx 在进行匹配之前删除了 args。但我不知道如何获得包括 args 在内的匹配项。

我想出了一个非常接近 Tero 的解决方案。

location ~ /(path1|path2|path3) {
    if ($arg_id) {
        rewrite ^ $uri/item break;
     }
     proxy_pass http://local.xxx.ins:8080;
}
Run Code Online (Sandbox Code Playgroud)

nginx

0
推荐指数
1
解决办法
5501
查看次数

限制 NGINX 上的子域访问

我有一个域,它叫做mydomain.com,它在 NGINX 服务器上运行。我在sites-enabledfor上添加了新配置subdomain.mydomain.com,它起作用了。

但是当我访问, whatever.mydomain.com, 时wildcard.mydomain.com,NGINX 不显示 404,但它的执行配置类似于mydomain.com.

如何限制访问子域,仅适用于启用站点的可用配置?

ubuntu nginx subdomain

0
推荐指数
1
解决办法
735
查看次数

nginx 服务其他域然后我自己的

我在 nginx 将流量传递到我的站点而不是我自己的域时遇到了一些问题。

似乎“fb.citroen.nl”的 dns 设置错误(到我的服务器)。我想在 nginx 级别阻止除 bviaene.sanderdeclerck.be 和 www.bviaene.sanderdeclerck.be 之外的所有流量,以减少服务器负载。

搜索后,我看到它应该在 /etc/nginx/sites-enabled/default 中完成。我认为它已正确设置,但 fb.citroen.nl 的流量仍然显示我的网站。

这是我的 /etc/nginx/sites-enabled/default:

# bviaene

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        server_name bviaene.sanderdeclerck.be www.bviaene.sanderdeclerck.be;

        location / {
                proxy_pass http://localhost:5000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection keep-alive;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }
}
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么?

编辑:我确实用'sudo nginx reload -s'重新加载了nginx

ubuntu nginx

0
推荐指数
1
解决办法
58
查看次数

如果我在 nginx 上使用 HSTS,网站是否会强制重定向到 HTTP?

我需要通过 HTTP 访问一些图像和 JS 文件,但是如果我使用 启用 HSTS add_header Strict-Transport-Security "max-age=31536000";,则所有文件都通过 HTTPS 强制提供。

所以我使用了add_header Strict-Transport-Security "max-age=0;".

是否有启用 HSTS 的通过 HTTP 访问文件的方法?

ssl nginx openssl hsts

0
推荐指数
1
解决办法
522
查看次数

添加ssl后Nginx不会重启

我添加了一些修改我的 root@mypage:/etc/nginx/sites-available/default

当我这样做时sudo service nginx restart ,服务器会返回此错误:Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

如果我运行nginx -t -c /etc/nginx/nginx.conf输出是

Enter PEM pass phrase: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful

有人可以告诉我我做错了什么吗?我在这里完全空白

这是root@mypage:/etc/nginx/sites-available/default文件

 server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;

    server_name mypage.com;
    passenger_enabled on;
    rails_env    production;
    root         /home/deploy/mypage/current/public;

    # redirect server error pages to …
Run Code Online (Sandbox Code Playgroud)

ssl vps nginx ssl-certificate

0
推荐指数
1
解决办法
2595
查看次数

标签 统计

nginx ×10

ubuntu ×3

ssl ×2

cache ×1

centos ×1

fastcgi ×1

fedora ×1

hsts ×1

memory ×1

openssl ×1

php ×1

php-fpm ×1

saas ×1

ssl-certificate ×1

subdomain ×1

vps ×1

vultr ×1