these days tinkering with the company's website, the use of Nginx+tomcat collaborative work, some things to do a related backup, in case of later work in use
1. Stop Nginx: Stop operation is done by sending a signal to the nginx process.
Step 1: Query the Nginx main process number
Ps-ef | grep nginx
Find the master process in the list of processes, whose number is the main process number.
Step 2: Send a signal
Calmly stop Nginx:
Kill-quit Main process Number
Quick Stop Nginx:
Kill-term Main process Number
Force Stop Nginx:
Pkill-9 Nginx
In addition, if the nginx.conf configuration of the PID file storage path, the file is stored in the Nginx main process number, if not specified in the Nginx logs directory. With the PID file, we do not have to query the Nginx main process number, and directly to the nginx sent a signal, the command is as follows:
Kill-Signal type '/usr/nginx/logs/nginx.pid '
Smooth restart
If you change the configuration to restart Nginx, you need to turn off the nginx before opening? No, can send a signal to nginx, smooth restart.
Smooth Restart command:
Kill-hup live in title or process number file path
or use
/usr/sbin/nginx-s Reload
Note that after modifying the configuration file, it is best to check the correct configuration file, so as not to restart after the Nginx error affecting the stable operation of the server. Determine if the Nginx configuration is the correct command as follows:
Nginx-t-c/usr/nginx/nginx.conf
Or
/usr/sbin/nginx-t
2. Start Nginx
Start command: /usr/sbin/nginx-c/usr/nginx/nginx.conf
-C Setting the path to the configuration file
3. nginx Domain Access configuration
The configuration file for the domain name a:www.a.com is as follows: (sample)
server { listen ; server_name *.a.com; Location/{ Proxy_pass http://localhost:8080/projectA/; Proxy_set_header Host $host; Proxy_set_header x-real-ip $remote _addr; Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; }}
I actually do:
upstream tomcat_web{ Server localhost:8080 weight=10; } server {Listen default_server; Listen [::]:80 default_server; server_name www.XXXXXX.net; #index index.jsp # root/home/microlink/app/site; # Load configuration files for the default server block. include/etc/nginx/default.d/*.conf; Location/{#jsp网站程序根目录, General Nginx and Tomcat in the same directory root/home/xxx/xxx/site; Index index.html index.jsp index.html; } location ~. *\.jsp$ {proxy_connect_timeout 3; Proxy_send_timeout 30; Proxy_read_timeout 30; Proxy_pass http://localhost:8080; Proxy_set_header Host $host; Proxy_set_header X-real-ip $remote _addr; Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; }
4. Firewall open, close and status query
- View the firewall status.
Systemctl Status Firewalld
- View firewall status
Chkconfig iptables--list
- Temporarily shuts down the firewall command. After restarting your computer, the firewall is automatically up.
Systemctl Stop Firewalld
- Permanently shuts down the firewall command. After rebooting, the firewall does not start automatically.
Systemctl Disable FIREWALLD
- Open the Firewall command.
Systemctl Enable Firewalld
- (1) Permanent effect after reboot:
- Open: Chkconfig iptables on
OFF: Chkconfig iptables off
(2) Immediate effect, failure after restart:
Open: Service iptables start
Close: Service iptables stop
It should be stated that for other services under Linux, the above command can be used to perform the open and close operations.
When the firewall is turned on, make the following settings, open the relevant port,
Modify the/etc/sysconfig/iptables file to add the following:
-A rh-firewall-1-input-m state--state new-m tcp-p tcp--dport 80-j ACCEPT
-A rh-firewall-1-input-m state--state new-m tcp-p tcp--dport 22-j ACCEPT
Or:
/etc/init.d/iptables status will get a series of messages stating that the firewall is open.
/etc/rc.d/init.d/iptables Stop shutting down the firewall
At last:
Enter setup under the root user, enter a graphical interface, select Firewall configuration, go to the next interface, select the security level for disabled, save. Reboot.
======================================================
Under Fedora
/etc/init.d/iptables stop
=======================================================
Under Ubuntu:
Since Ubuntu does not have the relevant direct commands
Please use the following command
Iptables-p INPUT ACCEPT
Iptables-p OUTPUT ACCEPT
Temporarily open all ports
There's no command to close iptables on Ubuntu.
=======================================================
Iptables is the next powerful Linux firewall, without considering the efficiency of the case, powerful enough to replace most hardware firewalls, but the powerful firewall if the application is not appropriate, may be blocking is not just the potential attacks, and may be your own oh. The harm to the ordinary personal PC may not matter, but imagine if this is a server, if this happens, not only the normal theater services, but also to the scene to recover, which will bring you how much loss?
So what I'm trying to say is that you have to be very careful when you're typing in each of the iptables related commands.
1. When applying each rule to drop target, check the rules carefully and consider the impact he has on you before applying them.
2. In Redhat we can use the service iptables stop to turn off the firewall, but in some versions such as Ubuntu This command does not work, you may search the Internet a lot of articles tell you to use iptables-f this command to shut down the firewall, But before using this command, remember to use IPTABLES-L to see the default target,iptables-f for all the chains in your system. This command just clears all the rules. Only does not really shut down the iptables. Imagine if your chain default target is drop, you have rules to allow certain ports, but once the iptables-l is applied and all rules are cleared, the default target will block any access. Of course you include the remote SSH Management Server.
So I recommend that the Shut down firewall command is
Iptables-p INPUT ACCEPT
Iptables-p FORWARD ACCEPT
Iptables-p OUTPUT ACCEPT
Iptables-f
In short, when you want to make any changes to your server, it is best to have a test environment that has been fully tested and applied to your server. In addition, to use good iptables, it is necessary to understand the iptables operation principle, know how each packet iptables how to deal with. In this way, the rules can be written accurately to avoid unnecessary trouble.
Reference Links:
<1>http://bbs.51cto.com/thread-1095321-1-1.html
<2>http://blog.csdn.net/kobejayandy/article/details/20867351
<3>http://www.cnblogs.com/freespider/p/4684586.html
<4>http://blog.csdn.net/tongzidane/article/details/42291857 (nginx installation, configuration, etc.)
The above describes the basic use of nginx (start, close and Domain name Mapping access), including the content, I hope that the PHP tutorial interested in a friend helpful.