问题:

想实现访问在同一个主机上实现多个域名访问,

如用 blog.xxx.com访问博客(使用8000端口),

app.xxx.com访问其他应用(使用8080端口);

不同的服务用URL区分,不用输入端口;

尝试方法:

按照网上的说法,在nginx的配置文件(nginx.conf)中增加了proxy_pass选项;

大致配置如下:

server
    {
        listen 80 ;
        index index.html index.htm index.php;
        root /home/www/blog;
         include enable-php-pathinfo.conf;
        server_name blog.coreylam.link;
        location / {
            proxy_pass http://127.0.0.1:8000;
        }
        access_log  /home/wwwlogs/blog_access.log;
    }
server
    {
        listen 80 ;
        index index.html index.htm index.php;
        root /home/www/app;
        include enable-php-pathinfo.conf;
         server_name app.coreylam.link;
        location / {
             proxy_pass http://127.0.0.1:8080;
        }
        access_log  /home/wwwlogs/app_access.log;
    } 

出现问题:

配置后重启nginx,发现两个都无法访问,报502错误;

相关文章:

  • 2021-05-28
  • 2022-01-31
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2021-05-26
  • 2022-12-23
  • 2021-07-18
相关资源
相似解决方案