To deploy multiple sites on a server, you need to open multiple ports to access different sites. The process is very simple. It took 2 hours to debug. Here is a record: Main domain name multi-port access Set up an A record in the DNS NameServer Point www.xxx.com to the server ip Open the required ports and modify the nginx configuration file For example, we have two services open on port 80 and port 8080 respectively. If there is iptable, open the port first: iptables -A INPUT -ptcp --dport 80 -j ACCEPT iptables -A INPUT -ptcp --dport 8080 -j ACCEPT Modify the configuration file: #path: /usr/local/nginx/conf/nginx.conf server { listen 80; server_name www.xxx.com; access_log /data/www/log/33.33.33.33_nginx.log combined; index index.html index.htm index.php; include /usr/local/nginx/conf/rewrite/none.conf; root /data/www/website/33.33.33.33:80; location ~ [^/]\.php(/|$) { fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } } server { listen 8080; server_name A.xxx.com; access_log /data/www/log/33.33.33.33:8080_nginx.log combined; index index.html index.htm index.php; include /usr/local/nginx/conf/rewrite/none.conf; root /data/www/website/33.33.33.33:8080; location ~ [^/]\.php(/|$) { fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } } The key is the two server sections. You can also split these two sections into two configuration files and put them in /etc/nginx/conf.d/ Below the directory; Subdomain multi-port access This kind of access is silly, because your access to port 8080 needs to be in the format of http://xxx.com:8080; And if there are two different cgis, for example, port 80 corresponds to a php web service, and port 8080 corresponds to a nodejs web service; and our nodejs comes with a web service that is already listening on port 8080, what should we do? At this time, we need the reverse proxy function of Nginx and add an A record on the DNS Server to finally achieve
Add an A record Point A.xxx.com to the server ip The Nginx configuration template is as follows: #path: /usr/local/nginx/conf/nginx.conf server { listen 80; server_name www.xxx.com; access_log /data/www/log/33.33.33.33_nginx.log combined; index index.html index.htm index.php; include /usr/local/nginx/conf/rewrite/none.conf; root /data/www/website/33.33.33.33:80; location ~ [^/]\.php(/|$) { fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } } server { listen 80; listen [::]:80; server_name A.XXX.com; proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; fastcgi_send_timeout 300s; fastcgi_read_timeout 300s; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; try_files $uri $uri/ =404; } } nginx reloads the configuration file nginx -s reload 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:
|
<<: Detailed explanation of the use of React list bar and shopping cart components
>>: Detailed explanation of MySQL database addition, deletion and modification operations
Effect: The title has its own serial number, the ...
Table of contents 1. Overview 2. Attributes 1. Ma...
This article describes how to set the automatic c...
Preface I recently encountered a problem at work....
Introduction to Linux top command The top command...
For a long time, website development was hampered...
Table of contents How to start mysqld Method 1: m...
The content involved in Web front-end development...
Software Download Download software link: https:/...
The span tag is often used when making HTML web p...
Preface: In the daily use of the database, it is ...
Because li is a block-level element and occupies ...
<br />For each of our topics, the team will ...
Table of contents 1. What is lazy loading of rout...
Mainly for low version browsers <!-- --> is ...