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

The implementation method of forwarding Domain name to designated Port in Nginx

2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Enter / usr/local/nginx/conf

Sudo cd / usr/local/nginx/conf

Create a vhost directory

Sudo mkdir vhost

Modify the nginx.conf file

Sudo cp nginx.conf nginx.conf_backsudo vim nginx.conf

Set up the hosts file of the access machine in order to simulate the access. The machine I use here is the windows 10 System32 hosts file in the C:\ Windows\ System32\ drivers\ etc folder.

Create a port proxy profile

Sudo cd vhostsudo vim www.jaydenmall.com.confserver {# listens on port 80 listen 80; autoindex on; server_name www.jaydenmall.com; access_log / usr/local/nginx/logs/access.log combined; index index.html index.htm index.jsp index.php; if ($query_string ~ * ". * [\;'\]. *") {return 404 } location / {# reverse proxy to port 8080 proxy_pass http://127.0.0.1:8080; add_header Access-Control-Allow-Origin *;}}

Restart nginx

Sudo. /.. / sbin/nginx-s reload

Errors may occur, and you need to use the parameter nginx-c to specify the location of the nginx.conf file.

Sudo killall-9 nginx # Kill the nginx process sudo / usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.confsudo. /.. / sbin/nginx-s reload # restart

The port reverse proxy is successful. Note that the red part is the default port 80, which actually points to port 8080, which is indeed tomcat.

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