nginx安装及配置
1.解压
tar xzvf nginx-1.23.1.tar.gz
2.改名
mv nginx-1.23.1 nginx
3.配置
cd nginx ./configure --prefix=/usr/local/nginx
4.编译安装
make && make install
5.软链接
ln -s /usr/local/nginx /usr/bin/nginx
6.配置:
location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
7.nginx项目缺失“Content-Security-Policy”
add_header Content-Security-Policy "default-src *;style-src 'self' 'unsafe-inline';script-src 'self' 'unsafe-inline' 'unsafe-eval';img-src * data:;worker-src * blob:;font-src 'self' data:;"; add_header X-Content-Type-Options "nosniff"; add_header X-XSS-Protection "1";
8.代理websocket
location / { proxy_pass http://172.10.0.41:8888; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; }
9.安装参数参考
--prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --modules-path=/usr/local/nginx/modules --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/nginx/error.log --http-log-path=/usr/local/nginx/logs/nginx/access.log --pid-path=/usr/local/nginx/run/nginx.pid --lock-path=/usr/local/nginx/run/nginx.lock --http-client-body-temp-path=/usr/local/nginx/client_temp --http-proxy-temp-path=/usr/local/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-openssl=/root/openssl-1.1.1q --add-module=/root/ngx_http_proxy_connect_module --with-ipv6