nginx - How does Ngnix use http and https at the same time in a server?
巴扎黑
巴扎黑 2017-05-16 17:29:59
0
3
600

My current nginx configuration is

server {
  listen 80;
  ...
}

server {
  listen 443;
  ssl on;
  ...
}

But the other configurations in the two servers are exactly the same, which makes me sick to death. . . Is there any way to make the same server listen to 80 and 443, and then use http and https at the same time?

巴扎黑
巴扎黑

reply all(3)
淡淡烟草味
listen              80;
listen              443 ssl;
漂亮男人

In addition to the method above, there is another way
Because there will be a cluster when there is a lot of traffic, upsteam will be used. You can transfer both 443 and 80 to port 80.

左手右手慢动作

https://ma.ttias.be/force-redirect-http-https-custom-port-nginx/

server {
listen 1234 ssl;
server_name your.site.tld;
ssl on;
...
error_page 497 https://$host:1234$request_uri;
...
}

Customized port, forced jump can be used

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!