前提:电脑中最好装有Xshell 和 Winscp等工具,方便操作和传输。
-- 找到nginx的配置文件 /etc/nginx/nginx.conf 进入编辑,在server标签下,找到 location字段
-- 在location /{}中, /后面为url映射,{}中添加目标url 例如:proxy_pass http://127.0.0.1:8081;
-- 这样在访问默认端口时(localhost 本地端口) 实际内容会显示8081端口的内容。
-- 有几个项目 就定义几个server。
... #全局块
events { #events块
...
}http #http块
{
... #http全局块
server #server块
{
... #server全局块
location [PATTERN] #location块
{
...
}
location [PATTERN]
{
...
}
}
server
{
...
}
... #http全局块
}
--日志问题,http字段中找到 log_format 如下
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$upstream_addr $upstream_response_time $request_time ';
access_log /data/nginx/access.log main;
上段为日志默认格式规定,下段为日志存放路径和格式。 改变默认路径,在访问的时候linux会自动创建日志文件。

3757

被折叠的 条评论
为什么被折叠?



