整了個微服務,老大說https跨域一直有問題,wtf?這個東西我都寫過多少遍了,我感受是他作的nginx跳轉有問題,可是咱也不敢說啊,本身用nginx測一下唄。html
我採用的是compose的安裝方式,服務器是百度雲的nginx
cd /
mkdir compose
cd compose
touch docker-compose.yml
vim docker-compose.yml
複製代碼
docker-compose.yml文件docker
version: '2.0'
services:
nginx:
image: nginx
container_name: nginx
volumes:
- ./conf.d:/etc/nginx/conf.d/
- ./www:/www
- ./cert:/etc/nginx/cert
ports:
- "80:80"
- "443:443"
複製代碼
我將conf.d跟cert目錄放在docker-compose相同路徑下,而後將個人ssl key文件放到cert目錄下 例如:vim
而後去編寫配置文件cd ../conf.d
touch default.conf
vim default.conf
複製代碼
default.conf:跨域
server {
listen 443;
server_name sudooom.com;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/sudooom.com.crt;
ssl_certificate_key cert/sudooom.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://x.x.x.x:10003 ;##填須要跳轉的ip
# add_header Access-Control-Allow-Origin * ;
}
}
複製代碼
docker-compose up -d
複製代碼