nginx requests are forwarded to tomcat (port forwarding)

Assuming that the jdk/nginx/tomcat environment is installed

4. Port forwarding

You need to forward port 80 to the tomcat home page running on the server, and its port is 8080.

tomcat home page:

write picture description here

Configure the nginx.conf file of nginx as follows:

server {
        listen       80;
        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #index  index.html index.htm;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_pass http://127.0.0.1:8080;
        }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

Restart the nginx service, ./nginx -s reload

At this point, you can access port 80, but it is actually a service that jumps to port 8080.

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325374188&siteId=291194637