Home > front end >  Nginx reverse proxy, unable to load a CSS pictures inside, white
Nginx reverse proxy, unable to load a CSS pictures inside, white

Time:12-08

Because there are two projects under a domain name, so they distinguish through http://www.aaaa.com/testa/and http://www.aaaa.com/testb/, if the domain name to point directly/testa and/or testb can be normal visit, their nginx port changed to 8081 and 8082, with IP and port number is also can be accessed directly, but used the nginx white during the reverse proxy, the configuration is as follows:
There is no output error log, but bad, don't load the CSS, images and other in
If it is normal browsing, can finish load index. The HTML these CSS and js, continue to load the CSS defined inside pictures,
Project directory is only index. The HTML and static directory,

CodePudding user response:

Image is returned an address,

CodePudding user response:

reference 1st floor qq_45713941 response:
image returns an address,

Picture is written in the CSS development, are../../static/img/address

CodePudding user response:

Directly in HTML to write image path, direct just write how is static, dynamic will write on img src=https://bbs.csdn.net/topics/'",

CodePudding user response:

https://blog.csdn.net/m0_37852904/article/details/87780361, don't know if this post

CodePudding user response:

If you don't guess correctly, the inside of the CSS pictures using the absolute address
Is similar to/images/a. pg

Rather than a relative address../images/a. pg

CodePudding user response:

medical hand references 5 floor response:
if not guess wrong, the inside of the CSS pictures using the absolute address
Is similar to/images/a. pg

Rather than a relative address../images/a. pg


Use url (../.. This/static/img/Amy polumbo ng)

CodePudding user response:

reference qq_45713941 reply: 3/f
directly in HTML to write image path, how to directly write line is static, dynamic will write on img src=https://bbs.csdn.net/topics/", "

https://blog.csdn.net/m0_37852904/article/details/87780361, don't know if this post

CodePudding user response:

So now the state of the machine is
http://127.0.0.1:8081 is a normal
http://127.0.0.1:8081/testa is abnormal
http://www.aaaa.com/testa/is abnormal

And the focus of the anomaly is white, did not even, according to the basic HTML and not just the picture didn't show?

CodePudding user response:

refer to the eighth floor medical hand response:
so the machine state is
http://127.0.0.1:8081 is a normal
http://127.0.0.1:8081/testa is abnormal
http://www.aaaa.com/testa/is abnormal

And the focus of the anomaly is white, did not even, according to the basic HTML and not just the picture didn't show?

Yes, bad, nothing shows that I didn't see error in log also

CodePudding user response:

You this rather then the secondary directory to access to the application! In this way to require the following:
1. The Location and configuration must add/behind;
2. The application itself is also a built in the form of secondary directory;
3. The static resources must use relative address, using an absolute address can access exception, some style and pictures showed not to come out!

Case:
 the location/ABU/{
Proxy_pass http://abu_server/abu/;
}

The location/h1/{
Proxy_pass http://10.18.5.135:9288/h1/;
}


Remember the last add a/


IIS deployment web site, is also carried out in accordance with the equivalent to level 2 directory way!

CodePudding user response:

So when the forwarding agent, not with testa or testb, should the following configuration,
 server {
Listen, 80;
Server_name www.aaa.com;

The location ~/{
Expires - 1;
Proxy_read_timeout 600 s;
Proxy_next_upstream_tries 1;
Client_max_body_size 100 m;
If ($request_uri ~ "/testa/(/^? {
*) ")The set $path $1;
Rewrite./$path;
Proxy_pass http://127.0.0.1:8081;
break;
}
If ($request_uri ~ "/testb/(/^? {
*) ")The set $path $1;
Rewrite./$path;
Proxy_pass http://127.0.0.1:8082;
break;
}
charset utf-8;
Proxy_pass http://127.0.0.1:8083;
}
}

CodePudding user response:




11 references, medical hand response:
so when the forwarding agent, not with testa or testb, should the following configuration,
 server {
Listen, 80;
Server_name www.aaa.com;

The location ~/{
Expires - 1;
Proxy_read_timeout 600 s;
Proxy_next_upstream_tries 1;
Client_max_body_size 100 m;
If ($request_uri ~ "/testa/(/^? {
*) ")The set $path $1;
Rewrite./$path;
Proxy_pass http://127.0.0.1:8081;
break;
}
If ($request_uri ~ "/testb/(/^? {
*) ")The set $path $1;
Rewrite./$path;
Proxy_pass http://127.0.0.1:8082;
break;
}
charset utf-8;
Proxy_pass http://127.0.0.1:8083;
}
}


This configuration access or hang, IP and port access is good, is it possible is a question of his program

CodePudding user response:

All browsers hang or some
Open a console and see if there is any error

CodePudding user response:

The
reference 13 floor console. The log () response:
all browsers hang or some
Open a console and see if there is any error

All browsers are white, the console without error, nginx no error

CodePudding user response:

You mean there is no request for the image or load but return is empty?

CodePudding user response:

reference _ 15 floor bath fire phoenix response:
what do you mean no request for the image or load but return is empty?

No request for the image

CodePudding user response:

The request for the image no pictures of CSS is to check the returned CSS content is properly
Picture is from the HTML will check the contents of the HTML is correctnullnull