Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
配置nginx指向Jenkins服务器时出错_Nginx_Jenkins - Fatal编程技术网

配置nginx指向Jenkins服务器时出错

配置nginx指向Jenkins服务器时出错,nginx,jenkins,Nginx,Jenkins,我让Jenkins在CentOS 7虚拟机上运行,IP地址为129.215.193.34。因此,我可以使用129.215.193.34:8080访问Jenkins。我想使用nginx,这样用户就不必键入:8080,只需输入IP号码。 在安装nginx并在/etc/nginx/nginx.conf中插入以下内容之后 location / { proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_hea

我让Jenkins在CentOS 7虚拟机上运行,IP地址为129.215.193.34。因此,我可以使用
129.215.193.34:8080
访问Jenkins。我想使用
nginx
,这样用户就不必键入
:8080
,只需输入IP号码。 在安装nginx并在/etc/nginx/nginx.conf中插入以下内容之后

location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
但访问
129.215.193.34
时,我遇到了一个一般性错误。我怎么知道这里出了什么问题?我可以在
129.215.193.34:8080上看到Jenkins的web界面,但在
129.215.193.34上什么也看不到

nginx.conf
的其余部分如下所示

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        location / {
           sendfile off;
           proxy_pass         http://127.0.0.1:8080;
           proxy_redirect     default;

           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto $scheme;
        }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

您可以通过运行(以root用户身份)来验证nginx配置是否正确

如果这是正确的,请检查代理是否工作(您应该在nginx配置中找到一些内容)。跑

然后卷曲到机器上

curl -I http://<ip>:80/

在主机上。

您有服务器部分吗?你能把整个nginx配置文件放在这里吗?@Rik当然,对不起。让我更新它。尝试更改仅侦听外部ip的
服务器
部分<代码>收听129.215.193.34:80 deafult_服务器
并重新启动nginx。在位置中有一个重复的
proxy\u重定向
,但您只需要让它工作
proxy\u过程
。所以你可能想先试试。实际上我认为
proxy\u重定向关闭为你而吹。只需使用
location/{…}
中的前3行并检查that@Rik我尝试了
位置
部分中的这三行,但都不起作用。还将
listen
部分替换为
listen 129.215.193.34:80 deafult_服务器
,但我在重新启动nginx的
作业时出错。服务失败,因为控制进程已退出,并带有错误代码。
tail -f /var/log/nginx/error.log 
curl -I http://<ip>:80/
setsebool -P httpd_can_network_connect on