服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

在Serverpilot上configuration301redirect强制https:// no-www的最佳方式(nginx / apache服务器)

现在的情况: 我成功地设法在我的Serverpilot(nginx / apache)服务器上手动设置SSL证书。 因为我的网站在Serverpilot服务器上运行,所以部分是nginx,部分是Apache。 我可以在我的服务器上执行Apache中的所有redirect,但我更喜欢在我的nginxconfiguration文件中以正确的方式执行,因为我已经读过这种方法。 由于nginx由serverpilotpipe理,所以我必须在位于我的服务器上的这个文件夹中的一个单独的nginxconfiguration文件中进行更改:/etc/nginx-sp/vhosts.d。 如您所见,Serverpilot不使用标准nginxconfiguration,Serverpilot安装来自Serverpilotconfiguration文件。 这个/etc/nginx-sp/vhosts.d文件夹中有两个文件: example.conf(这是Serverpilot的标准configuration文件,我没有改变它) example.ssl.conf(这是我用ssl规则创build的文件) 据我所知,Nginx首先读取第一个.conf文件,然后读取第二个.conf文件。 那是对的吗? 什么 example.conf(Serverpilot标准configuration文件)包含以下内容: server { listen 80; listen [::]:80; server_name server-example example.net www.example.net ; root /srv/users/serverpilot/apps/example/public; access_log /srv/users/serverpilot/log/example/example_nginx.access.log main; error_log /srv/users/serverpilot/log/example/example_nginx.error.log; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; include /etc/nginx-sp/vhosts.d/example.d/*.nonssl_conf; include /etc/nginx-sp/vhosts.d/example.d/*.conf; } 我创build了一个包含以下内容的example.ssl.conf: server { listen 443 ssl http2; listen […]

从systemd运行一个bash脚本,就像我login一样

我有一个服务作为bash脚本实现。 里面实际上是一个节点应用程序,但是对于这个问题,它可能是任何东西。 基本用例是我们在交互式shell中开发/debugging脚本,然后将其作为服务启用。 如果我ssh到我的设备(login)我的整个环境在那里,我可以在命令行启动我的脚本,没有问题。 我所在的shell已经从.bashrc,.profile等中选取了合适的环境,并且一切正常。 但是,如果我从一个systemd服务启动它,它会像交互式shell一样获得环境。 有条款给环境variables添加环境variables,但是我在这里所做的只是重复了我的交互环境所做的事情,并成为一种简单的方法来忘记一些事情。 对于一个真正的生产服务,我确信有一个正确的方法来做到这一点,但这是一个实验室应用程序,我需要简化,所以没有人在脚本上工作需要知道系统如何工作。 所以问题是:我需要做什么才能让脚本写在交互式bash shell下运行,从systemd运行? 我试图用–login启动bash,但是这不起作用。 也不在外部脚本中明确地执行源.bashrc。 以下是我正在处理的示例,以突出显示问题: 核心脚本(job.sh): #!/bin/bash cd while [ 1 ] do pwd echo USER is $USER echo PATH is $PATH which node node –version sleep 1 done 我从另一个脚本(wrapper.sh)调用它: #!/bin/bash echo starting wrapper… bash –login /home/droid/job.sh 这里是我在/etc/systemd/system/job.service中的job.service单元: [Unit] Description=Job Daemon [Service] User=droid ExecStart=/home/droid/wrapper.sh [Install] WantedBy=multi-user.target 我对systemd有什么不了解,这让我无法正常工作?