如上图所示,指定域名为www.aaa.com 如果将server.js的prot值改为80可以正常访问,但80有其他项目在用这个项目想用3333
备注:因项目比较有针对性,本地访问也必须是域名形式才能正常
在网上看到也有类似的需求 如:https://segmentfault.com/q/10...
解决方案是http-proxy 但我安装后还是不太会配置
PHP中文网2017-04-17 15:56:54
The problem has been solved. I develop under windows and use nginx as a reverse proxy
The first step of installation
http://www.cnblogs.com/wenanr... Refer to the introduction of this article (I just started searching the official website to download the latest one directly, but it didn’t work. Later I saw the download link in this article After downloading the settings, it was successful. Note: It may be that I made a mistake in other operations)
The second step is to configure the reverse proxy
Find the nginx.conf file in the conf folder in the nginx directory you installed, and find server{ in the file ……} Start a new line and add the following code:
server{
listen 80;
server_name www.test.com;
location /{
proxy_pass http://127.0.0.1:3333;
}
}
You can modify the values of server_name and proxy_pass accordingly
Just restart nginx
伊谢尔伦2017-04-17 15:56:54
It should be ok
Local hosts
127.0.0.1 www.jiangli.com
You mean to access www.aaa.com directly to access your project, but the port of your project is 3333, so you can only use nginx to create a reverse proxy
When the port of your project is 80, the reason why you can access it through www.aaa.com is because the default requests are all port 80
www.aaa.com and www.aaa.com:80 are equivalent
ringa_lee2017-04-17 15:56:54
Either add the port number after the address, or use nginx or the like as a proxy