Nginx reverse proxy configuration, static resources cannot be loaded

Nginx reverse proxy jenkins configuration, jenkins main page is fine, but resources such as css and js cannot be loaded, are not familiar with nginx, and no suitable method has been found on the Internet.
nginx is configured as follows:


-sharpuser  nobody;
worker_processes  1;

-sharperror_log  logs/error.log;
-sharperror_log  logs/error.log  notice;
-sharperror_log  logs/error.log  info;

-sharppid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    -sharplog_format  main  "$remote_addr - $remote_user [$time_local] "$request" "
    -sharp                  "$status $body_bytes_sent "$http_referer" "
    -sharp                  ""$http_user_agent" "$http_x_forwarded_for"";

    -sharpaccess_log  logs/access.log  main;

    sendfile        on;
    -sharptcp_nopush     on;

    -sharpkeepalive_timeout  0;
    keepalive_timeout  65;

    -sharpgzip  on;

    server {
        listen       80;
        server_name  localhost;


        -sharpcharset koi8-r;

        -sharpaccess_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

    location /wsite {
        proxy_pass http://127.0.0.1:8090/;
    }

    location /jenkins {
        proxy_pass http://127.0.0.1:8080/;
    }

        -sharp redirect server error pages to the static page /50x.html
        -sharp
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        -sharp proxy the PHP scripts to Apache listening on 127.0.0.1:80
        -sharp
        -sharplocation ~ \.php$ {
        -sharp    proxy_pass   http://127.0.0.1;
        -sharp}

        -sharp pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        -sharp
        -sharplocation ~ \.php$ {
        -sharp    root           html;
        -sharp    fastcgi_pass   127.0.0.1:9000;
        -sharp    fastcgi_index  index.php;
        -sharp    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        -sharp    include        fastcgi_params;
        -sharp}

        -sharp deny access to .htaccess files, if Apache"s document root
        -sharp concurs with nginx"s one
        -sharp
        -sharplocation ~ /\.ht {
        -sharp    deny  all;
        -sharp}
    }


    -sharp another virtual host using mix of IP-, name-, and port-based configuration
    -sharp
    -sharpserver {
    -sharp    listen       8000;
    -sharp    listen       somename:8080;
    -sharp    server_name  somename  alias  another.alias;

    -sharp    location / {
    -sharp        root   html;
    -sharp        index  index.html index.htm;
    -sharp    }
    -sharp}


    -sharp HTTPS server
    -sharp
    -sharpserver {
    -sharp    listen       443 ssl;
    -sharp    server_name  localhost;

    -sharp    ssl_certificate      cert.pem;
    -sharp    ssl_certificate_key  cert.key;

    -sharp    ssl_session_cache    shared:SSL:1m;
    -sharp    ssl_session_timeout  5m;

    -sharp    ssl_ciphers  HIGH:!aNULL:!MD5;
    -sharp    ssl_prefer_server_ciphers  on;

    -sharp    location / {
    -sharp        root   html;
    -sharp        index  index.html index.htm;
    -sharp    }
    -sharp}

}
Jul.16,2021

should not have permission to access the directory

add the following configuration to the first line of nginx.conf

user root;

  1. lose the configuration and say you won't do it. The question is how do you match your jenkins? If you can't say how to do it, can you tell us the steps, or do you have to rely on metaphysics to answer this question?
  2. since jenkins is on port 8080, you should first visit port 8080 to see if it is normal. If 8080 is normal, it is not too late to doubt nginx; if 8080 is abnormal, you may need to consider the configuration of the java environment and whether there is a problem with file permissions.
  3. there is no problem with the nginx file in general. You can consider creating a new nginx user group (and users), and then use the user instruction to specify and then restart nginx, but it is generally not recommended to specify root, directly because you need to add separate parameters to start nginx later, and beginners are generally confused. Usually just keep the users running nginx consistent with the users you log on to ftp.
  4. if nginx is not easy to match, you can try that the configuration of caddy, is an order of magnitude simpler than nginx, and you can automatically add https. The documentation can be viewed directly on the official website, or you can search caddy Chinese documents, and it has a separate project with a configuration example in github, which is quick to get started.

there is something wrong with your jenkins configuration

Menu