3 篇文章带有标签 “webserver”

在 Mac 上安装 NGINX

安装

brew update
brew install nginx

启动服务

brew services start nginx
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon\ off\;
  • 编辑 /opt/homebrew/etc/nginx/nginx.conf 修改端口号
  • 编辑 /opt/homebrew/var/www/index.html 修改默认页面

停止服务

brew services stop nginx

重启服务 brew services restar

NGINX Reverse Proxy 反向代理

通过 CPU 服务器访问 GPU 服务器

NGINX 配置文件

sudo vim /etc/nginx/sites-available/default

配置反向代理

server {
    listen 8888;
    server_name cpu1;

    location / {
        proxy_pass http://cpu1:8300/;
    }
}

配置 WebSocket 反向代理

server {
    listen 8001;
    server_name cpu1;

    location / {
        proxy_pass http://gpu1:8001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

proxy_http_version 1.1proxy_set_header Upgrade $http_upgradeproxy_set_header Connection "upgrade"这些行是为了支持WebSocket连接。

配置多个反向代理 server { listen 8888; server_name cpu1; location /oneapi { proxy_pass http://cp

Apache HTTP Server实践

修改端口号

  • /etc/apache2/ports.conf
sudo nano /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8081
......
......
  • /etc/apache2/sites-enabled/000-default.conf
sudo nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:8081>
......
......
</VirtualHost>
  • 重启服务
sudo systemctl restart apache2

参考资料