One, foreword

Since I plan to do some interesting functional projects, I need to configure different Web projects (blog, personal projects, etc.) on my server first. Therefore, in order to map these static resources or services running in the background to nginx80 port, I have carried out some attempts.

Second, try to

  1. Nginx can resolve multiple domain names to the same IP address. Configure multiple servers to listen on port 80. Configure different server_name and root for each server.

    Again, why do I do, because it is a personal server, there is no record of the domain name, so this way to go, so skip.

  2. Nginx. conf/server/proxy_pass/proxy_pass/proxy_pass/proxy_pass/proxy_pass/proxy_pass/proxy_pass Configure a separate location mapping to the locally enabled http://127.0.0.1:8888/ project as follows:

server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location /blog {proxy_pass http://127.0.0.1:8888/; } the location ~. * \. (js) | CSS ${proxy_pass http://127.0.0.1:8888; }}Copy the code
  1. But if you want to multiple mapping project implementation, there is a I cannot solve the problem at present, the HTML file can be loaded, but the local open these projects of js, CSS files, don’t know how to distinguish, for each file if you want to rename to take regular matching to should match to the resource file, is also a more troublesome thing, And some files still cannot match the original path, will encounter the following error, so this method is abandoned.

  1. I don’t want to do too much, so I’ll open a port 90 for my new project.

Third, summary

Nginx, from the time I started to do the front, the project has the need to configure these, but only for local port different static resources do some debugging and configure HTTPS certificate, gzip the and so on, some problems still need professional operations staff to deal with, if there are familiar with the friend to see this article, could give me some advice, Thank you very much!