阿里云备案好之后我们应该做什么?nginx的正向、反向代理设置

版权声明:本文为HCG原创文章,未经博主允许不得转载。请联系[email protected] https://blog.csdn.net/qq_39455116/article/details/83901754

阿里云备案好之后我们应该做什么

1. 开放服务器的80端口

添加阿里云的安全组规则,不懂得可以百度一下
2. 添加域名解析

解析

3. 把nginx配置改一下

原来tomcat得端口不用改

server {
     listen 8091;
     server_name  hiiumaa.xiyou.club;
     location / {
     proxy_pass  http://localhost:8088;


    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
  }

把新的域名还有nginx监听地址改一下

listten改为80
 server_name  改为:www.neuqhcg.cn;

注意:不能直接把server_name改为你的域名neuqhcg.cn,一定要前面加上你的域名解析

比如说我的域名解析是:www.那我就可以把他改为www.neuqhcg.cn

或者你加了一个解析是ai.那也可以把server_name 改为 ai.neuqhcg.cn;

 server {
     listen 80;
     server_name  www.neuqhcg.cn;
     location / {
     proxy_pass  http://localhost:8088;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
  }

4. 重启nginx服务

service nginx restart

猜你喜欢

转载自blog.csdn.net/qq_39455116/article/details/83901754