Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Resolution of conflict between nginx and background Port

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Question:

When starting the development environment of the alice management system, it was found that all the interfaces in the background produced 404 errors in the first request, but the second request was successful.

Positioning problem

Check the nginx error log and find the following error, so it is mistakenly believed that the error occurred in the file caused by insufficient folder permissions in html can not be written, so after opening the permissions, it is found that it still does not work, and a search in Google still can not find a solution. Put it on hold for the time being, and when you re-find the error the next day, you inadvertently click on port 8081, and when you visit localhost:8081, the content of 127.0.0.1 is different from that of 127.0.0.1.

At that time found that the port conflict, so open the file below is nginx's config file and our project configuration file, found that there is a port conflict, when you access the background to find that the request will be specific to the nginx static file, resulting in 404 error.

Server {listen 8081; server_name 127.0.0.1; # charset koi8-r; # access_log logs/host.access.log main; location / {root html; index index.html index.htm;} server {# platform port listen 8100; server_name localhost; location / {proxy_pass http://localhost:4200/;} location / api/ {proxy_pass http://localhost:8081/; } # error_page 404 / 404.html; # redirect server error pages to the static page / 50x.html # error_page 500502503504 / 50x.html; location = / 50x.html {root / usr/share/nginx/html;}}

Solution method

Change the background port, and the configuration of the project is not nginx.

Remaining questions:

When starting in the background, the content of accessing localhost:8081 is different from 127.0.0.1

The same when the background is turned off

The reasons may be as follows:

Localhost: access the system with the permissions of the current local user

127.0.0.1: it means that the local computer accesses the local computer through the network.

When nginx conflicts with the background, why do you access nginx internal files odd times and even background times (why can you occupy the same interface)

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report