Nginx configuration 80 port access 8080 and project name address method analysis

Nginx configuration 80 port access 8080 and project name address method analysis

Tomcat accesses the project, usually ip + port + project name

Nginx configures location / {}, which can usually only jump to ip + port. If you want to access the project directly, you need to modify the tomcat configuration.

How to ensure that the port + project name can be accessed without modifying the configuration of tomcat and only modifying nginx

After trying, I found a way to

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

Jump to

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

demo is the project name, which is the file name configured under tomcat's webapps

This configuration will only display the project name in the URL address, but what does it matter?

Here is an example configuration:

upstream tomcatproject{
    ip_hash;
    server 11.1.11.11:8080;
    server 22.2.22.22:8080;
  }

  server {
    listen 80;
    #server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
        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_pass http://tomcatproject/demo;
    }

    location /demo/ {
        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_pass http://tomcatproject;
    }
}

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to configure nginx to ensure that the frps server and web share port 80
  • Solution to nginx configuration of multiple sites sharing port 80
  • Detailed explanation of nginx configuration to share port 80 with multiple tomcats
  • Detailed explanation of configuring multiple WeChat projects under one port 80 in Nginx reverse proxy
  • Detailed explanation of how to configure port forwarding other than port 80 in Nginx server
  • Detailed explanation of how to configure Nginx and Apache to share port 80
  • Blocking port 80: Nginx reverse proxy for WIN2003, super fool-proof configuration

<<:  MySQL 5.7.31 64-bit free installation version tutorial diagram

>>:  Analyze the difference between computed and watch in Vue

Recommend

How to implement Mysql switching data storage directory

How to implement Mysql switching data storage dir...

How to create a basic image of the Python runtime environment using Docker

1. Preparation 1.1 Download the Python installati...

How to install and modify the initial password of mysql5.7.18

For Centos installation of MySQL, please refer to...

Detailed steps to install Nginx on Linux

1. Nginx installation steps 1.1 Official website ...

What are the benefits of using B+ tree as index structure in MySQL?

Preface In MySQL, both Innodb and MyIsam use B+ t...

Summary of methods to include file contents in HTML files

In the forum, netizens often ask, can I read the ...

Detailed explanation of scp and sftp commands under Linux

Table of contents Preface 1. scp usage 2. Use sft...

Detailed explanation of the difference between run/cmd/entrypoint in docker

In Dockerfile, run, cmd, and entrypoint can all b...

MySQL 8.0.12 installation and configuration method graphic tutorial (windows10)

This article records the installation graphic tut...

CSS writing format, detailed explanation of the basic structure of a mobile page

1. CSS writing format 1. Inline styles You can wr...

Detailed analysis of the usage and application scenarios of slots in Vue

What are slots? We know that in Vue, nothing can ...

Example of converting timestamp to Date in MySQL

Preface I encountered a situation at work: In the...

Detailed explanation of the usage and function of MySQL cursor

[Usage and function of mysql cursor] example: The...

MySQL log trigger implementation code

SQL statement DROP TRIGGER IF EXISTS sys_menu_edi...