zoukankan      html  css  js  c++  java
  • 腾讯云Ubunt安装nginx

    安装nginx

    • 登录腾讯云服务器

    • 输入安装命令

    	sudo apt-get install ngnix
    
    • 查看相关信息
      查看软件包所在的目录,及该软件包中的所有文件
    	sudo dpkg -L ngnix
    
    • 看软件包的版本信息:
    	sudo dpkg -l ngnix
    
    • 启动nginx
    	sudo /etc/init.d/nginx start
    
    • 测试ngnix服务是否正常运行
    	wget http://127.0.0.1
    

    配置nginx

    nginx默认配置文件在 /ect/nginx/nginx.confg路径下

    该配置文件使用include包含了/ect/nginx/sites-available,/ect/nginx/sites-enabled下的所有文件,以及/ect/nginx/confi.d文件下所有的.config文件

    配置同IP不同端口代理(server配置)

    /ect/nginx/sites-enabled 路径下新建文件multiServer文件,写入以下内容

    这里我们将域名hel.h-five.com代理到当前ip的8081端口

    将域名icloud.h-five.com代理到当前ip的8081端口

    	## 域名一
    	server_name hel.h-five.com;
    
            location / {
                    proxy_pass http://127.0.0.1:8081;
    
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP  $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    	}
    
    	## 域名二
    	server_name icloud.h-five.com;
    
            location / {
                    proxy_pass http://127.0.0.1:8082;
    
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP  $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
            }
    	}	
    
    
    重新载入配置文件即可访问
    	sudo /etc/init.d/nginx reload
    
  • 相关阅读:
    Java-GZIPOutputStream踩坑
    Redis事务
    Netty实现简单群聊
    SpringMVC请求参数解析
    Netty实现WebSocket
    SpringBoot项目war包部署
    NIO实现群聊
    SpringMVC请求映射handler源码解读
    SpringMVC自定义兼容性HandlerMapping
    spring boot自定义类配置绑定在配置文件中自动提示
  • 原文地址:https://www.cnblogs.com/hlere/p/6745384.html
Copyright © 2011-2022 走看看