AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-40559

mahatmanich's questions

Martin Hope
mahatmanich
Asked: 2017-11-25 01:59:34 +0800 CST

nginx 多个(现在是两个)php 项目通过 php-fpm 在子目录中使用别名

  • 1

对于 nginx 的热爱,我无法解决这个问题。

期望:我想要两个简单的 php 项目(从长远来看是 wordpress)在一个服务器块下的两个子位置。旁注:这些项目位于使用 capistrano 部署的服务器上的两个不同目录中。

问题:我最终得到 404、403 或 index.php 的直接八位字节流下载。在后者上,我似乎找到了正确的 index.php,但它没有传递给 php-fpm 块。php-fpm 工作正常而不是问题(在其他没有子位置的服务器块中测试)

我已经浏览了整个网络,并尝试了数以百万计的“工作”配置,但它并没有融合在一起。

计划:下面你会看到一个工作的 nginx 虚拟主机,在正确的别名目录中点击正确的 index.html 文件。这样我就成功了一半。

在您的帮助下,我想调整下面的配置,将 index.php 更改index为 index.php 并让 php 处理location /staging和/production.

在location /production你看到一个配置(注释掉)我是如何尝试让 php 工作的。

server {
  listen 82;
  listen [::]:82;

  server_name nginx-web.ch;

  access_log /var/log/nginx/nginx-web_access.log;
  error_log /var/log/nginx/nginx-web_error.log;

  location  /staging {
    alias /var/www/nginx-web1/current;
    index index.html
    add_header X-debug-message "Location web1";
  }

  location /production {
    alias /var/www/nginx-web/current;
    index index.html
    add_header X-debug-message "Location web";

    #try_files $uri $uri/ /production/index.php;

    #location ~ \.php$ {
      # add_header X-debug-message "Location ~ php";
      # try_files $uri =404;
      # fastcgi_split_path_info ^(.+\.php)(/.+)$;
      # fastcgi_pass unix:/var/run/php5-fpm.sock;
      # fastcgi_index index.php;
      # include fastcgi_params;
      # fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #}
  }
}

这是一个工作服务器块,它试图适应子位置,但没有成功:(

server {
  listen 80;
  listen [::]:80;

  server_name testdev;

  access_log /var/log/nginx/wp_access.log;
  error_log  /var/log/nginx/wp_error.log;

  root /var/www;
  index index.php;

  location / {
    try_files $uri $uri/ /index.php?$args; 
  }

  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }
}

使用 WORKING CONFIG 更新(必须 <3 serverfault/stackoverflow):

这是最终的工作配置,非常感谢@RichardSmith

server {
    listen 82;
    listen [::]:82;

    server_name nginx-web.ch;

    access_log /var/log/nginx/nginx-web_access.log;
    error_log /var/log/nginx/nginx-web_error.log;

    index index.php;

    location ^~ /staging/ {
      alias /var/www/nginx-web1/current/;

      if (!-e $request_filename) { rewrite ^ /staging/index.php last; }

      location ~ \.php$ {
       if (!-f $request_filename) { return 404; }

       include fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME $request_filename;
          fastcgi_pass unix:/var/run/php5-fpm.sock;
       }
    }

    location /production {
      alias /var/www/nginx-web/current;

      if (!-e $request_filename) { rewrite ^ /production/index.php last; }

      location ~ \.php$ {
        if (!-f $request_filename) { return 404; }

        include fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME $request_filename;
          fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
    }
}
nginx
  • 1 个回答
  • 1994 Views
Martin Hope
mahatmanich
Asked: 2017-01-08 15:27:45 +0800 CST

在 debian 8 上使用 nginx 设置 xymon 在 cgi 脚本上给出 403

  • 0

我正在尝试在 debian 上使用 nginx 设置 xymon,并且我已经完成了初始设置。

但是,每当我点击 cgi 脚本时,我都会收到 403 错误。

这是我的设置:

server {
        listen 127.0.0.1:8081;

        server_name localhost;
        index       index.html;
        root        /var/lib/xymon/www;

        error_log /var/log/nginx/xymon.error.log;
        access_log /var/log/nginx/xymon.access.log;

        location /xymon/ {
                alias /var/lib/xymon/www/;
        }

        location /cgi-bin/ {
                alias /usr/lib/xymon/cgi-bin/;
        }

        location /cgi-secure/ {
                alias  /usr/lib/xymon/cgi-secure/;
        }

       location ~ ^/.*\.sh$ {
                gzip off;
                fastcgi_param SCRIPT_NAME $fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT /var/lib/xymon/;
                fastcgi_param REMOTE_USER $remote_user;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
       }
}

我试图从这个 freeBSD 设置中对其进行调整: https ://blog.feld.me/posts/2014/11/setting-up-xymon-with-nginx/

我得到一些无用的日志:127.0.0.1 - - [08/Jan/2017:00:25:14 +0100] "GET /cgi-bin/findhost.sh HTTP/1.1" 403 25

有没有人用 nginx 在 debian 上设置 xymon 并让它工作?

fastcgi nginx debian-jessie xymon
  • 1 个回答
  • 684 Views
Martin Hope
mahatmanich
Asked: 2016-03-27 16:04:45 +0800 CST

通过 su 获取 root 的 subshel​​l 的打印用户 -

  • 2

我可以su -在获得root后在root控制台上打印正在获得root访问权限的用户名吗?

user1$ su -
password:

obtained root via user1
#
linux
  • 2 个回答
  • 112 Views
Martin Hope
mahatmanich
Asked: 2016-03-26 14:14:46 +0800 CST

我可以限制openssh只允许带有密码短语的公钥吗?

  • 0
这个问题在这里已经有了答案:
如何判断公共 SSH 密钥是否有密码 3 个答案
6年前关闭。

是否可以使用PubkeyAuthentication yes但仅允许带有密码的 pub/private 密钥对来配置 ssh?

linux
  • 1 个回答
  • 67 Views
Martin Hope
mahatmanich
Asked: 2014-10-08 12:30:56 +0800 CST

仅主机网络 xen 4.4

  • 0

我有一个 IP 地址(ipv4),我正在尝试在 dom0 上安装一个 domU(debian stable),该 dom0 在 debian 测试中运行最新的 xen 4.4.1。

我已经创建了 xenbr0 网桥,它映射到我的 eth0。

我的 domU 可以使用xl create my.cfg并且安装程序(使用带有 initrd.gz 和 vmlinuz 的 debian 安装程序)启动。然后自动网络配置尝试通过我的 domU 中的 dhcp 获取 ip,但网络失败,因为我没有 dhcp 服务器。

如何手动设置我的 domU 以通过 xenbr0 连接到外部(野生互联网),以便我可以进行网络安装?

感谢您的任何指示。

更新:.cfg

真的没有什么特别的

kernel = "/tmp/vmlinuz"
ramdisk = "/tmp/initrd.gz"
extra = "debian-installer/exit/always_halt=true -- console=hvc0"
vcpus = 4
memory = 2048
name = "debianvm"
vif = ['bridge=xenbr0']
disk = ['phy:/dev/vg0/debianvm,xvda,w']
debian
  • 1 个回答
  • 1206 Views
Martin Hope
mahatmanich
Asked: 2013-09-11 03:07:24 +0800 CST

如何删除文件名有 utf-8 字符问题的文件

  • 4

我想通过bash rm命令从服务器中删除文件。

这是一个示例文件Test_ Mürz.jgp。

如何大规模删除文件名中具有此类字符问题的文件……尤其是当您不知道字符的位置时。

linux
  • 5 个回答
  • 7134 Views
Martin Hope
mahatmanich
Asked: 2012-11-05 11:35:51 +0800 CST

通过 fstab 使用凭据文件通过 cifs 安装 NAS 驱动器不起作用

  • 0

我可以通过以下方式安装驱动器,没问题:

mount -t cifs //nas/home /mnt/nas -o username=username,password=pass\!word,uid=1000,gid=100,rw,suid

但是,如果我尝试通过 fstab 挂载它,则会出现以下错误:

//nas/home /mnt/nas cifs  iocharset=utf8,credentials=/home/username/.smbcredentials,uid=1000,gid=100  0        0 auto

.smbcredentials 文件如下所示:

username=username
password=pass\!word

注意!在我的密码中......我在两种情况下都在逃避

:set noeol binary我还确保使用Mount CIFS Credentials File has Special Character的文件中没有 eol

chmod关于 .credentials 文件是0600并且chown是root:root文件在~/

为什么我进入一侧而不是 fstab?

我在 ubuntu 12 LTE 上运行,mount.cifs -V 给我 mount.cifs 版本:5.1

任何帮助和建议将不胜感激......

更新: /var/log/syslog显示以下

[26630.509396] Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE
[26630.509407] CIFS VFS: Send error in SessSetup = -13
[26630.509528] CIFS VFS: cifs_mount failed w/return code = -13

更新 2

通过 fstab 使用 strace mount 进行调试:

strace -f -e trace=mount mount -a
Process 4984 attached
Process 4983 suspended
Process 4985 attached
Process 4984 suspended
Process 4984 resumed
Process 4985 detached
[pid  4984] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid  4984] mount("//nas/home", ".", "cifs", 0, "ip=<internal ip>,unc=\\\\nas\\home"...) = -1 EACCES (Permission denied)
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Process 4983 resumed
Process 4984 detached

通过终端挂载

strace -f -e trace=mount mount -t cifs //nas/home /mnt/nas -o username=user,password=pass\!wd,uid=1000,gid=100,rw,suid
Process 4990 attached
Process 4989 suspended
Process 4991 attached
Process 4990 suspended
Process 4990 resumed
Process 4991 detached
[pid  4990] --- SIGCHLD (Child exited) @ 0 (0) ---
[pid  4990] mount("//nas/home", ".", "cifs", 0, "ip=<internal ip>,unc=\\\\nas\\home"...) = 0
Process 4989 resumed
Process 4990 detached
linux
  • 1 个回答
  • 8544 Views
Martin Hope
mahatmanich
Asked: 2010-04-15 05:20:36 +0800 CST

服务器安全 [重复]

  • -1
这个问题在这里已经有了答案:
保护 LAMP 服务器的提示 6 个答案
8年前关闭。

我想使用 debian lenny、apache2、php5、mysql、postfix MTA、sftp(基于 ssh)和可能的 dns 服务器运行我自己的根服务器(无需硬件防火墙即可从 Web 直接访问)。

您会推荐哪些措施/软件,以及为什么要保护此服务器并最大限度地减少攻击向量?除了Web应用程序...

这是我到目前为止所拥有的:

  • iptables(用于生成包过滤)
  • fail2ban(暴力攻击防御)
  • ssh (chang default, port disable root access)
  • modsecurity - 真的很笨拙而且很痛苦(这里有什么选择吗?)

  • ?Sudo 为什么要使用它?普通用户处理有什么好处

  • 为 mysql 考虑 greensql www.greensql.net
  • 绊线值得一看吗?
  • 打鼾?

我错过了什么?什么是热的,什么不是?最佳实践?

我喜欢“KISS” -> 保持简单安全,我知道它会很好!

提前致谢 ...

linux debian security
  • 3 个回答
  • 243 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve