In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "Nginx reverse proxy forwarding Apache configuration", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the configuration of Nginx reverse proxy forwarding Apache.
Option 1:
Point the domain name resolution to the address of the test server
Open relevant port access
Option 2:
Point the domain name resolution to one of the intranet test servers; (it is also convenient for testing https certificate problems)
The server forwards the service to the corresponding test server
Develop the port permissions of our test server and forwarded test server
At first, we used the * solution, but each time we had to trouble several groups of colleagues to deal with it, so we used option 2. Opened a transit server, set up a nginx service, and pointed to a server we are currently testing, during which we encountered problems. The operation and maintenance colleagues have no time, so let us do it ourselves. All right, there's a problem.
Question 1. Unable to find the corresponding project problem?
Because nginx is only responsible for forwarding requests to port 80 or other on that machine, it is not carefully configured, so the corresponding project cannot be found. Solution: add the appropriate vhost configuration to apache. The example is as follows:
DocumentRoot / www/web/madmin/public_html#ServerName admin.123.com#ServerAlias 10.8.0.1ServerName 192.168.1.212ErrorDocument 400 / errpage/400.htmlErrorDocument 403 / errpage/403.htmlErrorDocument 404 / errpage/404.html#php_admin_value open_basedir / www/web/madmin:/tmpDeflateCompressionLevel 7AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-phpAddOutputFilter DEFLATE css js html htm gif jpg png bmp phpOptions FollowSymLinksAllowOverride AllOrder allow,denyAllow from all
In this way, the server can parse the project normally.
Question 2. After forwarding it, the client ip can no longer get it, only a proxy server ip.
Because everything can be lost when it comes to forwarding, the original IP needs to be forwarded here, as follows:
Upstream apache {server 127.0.0.1 keepalive 80; keepalive 8;} upstream k_api {server 172.17.0.27 server 8080; keepalive 8;} server {listen 8091; server_name admin.123.com; location / api {proxy_pass proxy_set_header Host $host; # Domain forwarding proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; # IP forwarding proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 60 Proxy_read_timeout 600; proxy_send_timeout 600;} location / {proxy_pass http://apache/h6/; # forward to the server, add the relative directory address proxy_set_header Host $host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 60; proxy_read_timeout 600; proxy_send_timeout 600;}}
Question 3, after using the nginx agent, has been unable to log in, after troubleshooting as cookie can not be saved?
This problem has perplexed me for a long time, and I have sought advice from my operation and maintenance colleagues for a long time, but it has never been solved. In the end, I spent a lot of time looking for information, made many attempts, and finally found out. It turns out that it is the time difference of the server. The time zone of the nginx server is set to the time zone of the EST,apache server. The time zone setting of the EST,apache server is CST, and the time zone difference is 8 hours.
So cookie is invalid. The specific principle is that after logging in, cookie will be set on the server where the apache is located, which is valid for 1 hour, but after being transferred to nginx, the time has moved forward 8 hours, so the server (or the customer) will think that the cookie is expired, so it will not be saved.
Solution: change the nginx time zone and time, consistent with apache. The command to modify the time zone is as follows:
# Modification time date-s 12VO12 2017/01/12date time changed to 12:12:12date-s 20170112 # date changed to 2017/01/12date-s "12:12:12 2017-01-00" # time changed to 2017-01-00 12GRV 1mm modify time zone tzselect # modify to the corresponding time zone when prompted
Question 4. Listening port problem?
Set up to listen on the corresponding port as needed, and note that the port can not conflict!
At this point, I believe you have a deeper understanding of the "configuration of Nginx reverse proxy forwarding Apache". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.