0
여러 도메인을 사용하여 webpack-dev-server 용 프록시를 설정하려고합니다. 우리의 시스템은 다음과 같이 작동Webpack 3 프록시 다중 도메인
- login.domain.ext
- 이제 프로젝트는 로그인이 PHP 백엔드이며 그가 작동하는 동안, 웹팩 dev에 서버에서 실행
project.domain.ext dev 컴퓨터.
이 나는 포트에게 8080을 다시 추가 할 수 있도록 모든 반환 그러나 웹팩 도메인을 무시하는 것 같다 리디렉션 SSL 및 트랩에 로그인하기 위해 리디렉션하기 위해 프록시 설정을 설정 관리, 지금은 단지 역할 로그인 프로젝트에 대한 모든 것을 프록 싱하는 것처럼 말입니다.
disableHostCheck를 false로 설정하면 로그인 도메인 nog가 유효한 호스트로 오류가 발생합니다.
호스트 이름 프록시에서 찾을 수없는 모든 구성은 경로 프록시에 관한 것입니다. 하지만 이런 설정을 한 유일한 존재라고 상상할 수는 없습니다. 여기
내가 그것을 알아 냈import { configPath } from "../vars/paths.config";
const webpackMerge = require('webpack-merge');
const webpack = require('webpack');
import { commonConfig } from './common.config';
const fs = require('fs');
export let developmentConfig;
developmentConfig = {
devServer: {
historyApiFallback: true,
public : 'project.domain.ext.dev1:8080',
disableHostCheck: true,
https: {
key: fs.readFileSync(configPath + '/resources/ssl/san_domain_com.key'),
cert: fs.readFileSync(configPath + '/resources/ssl/san_domain_com.crt-extensions')
},
stats: {
colors: true
},
proxy: {
"https://login.domain.ext.dev1:8080/": {
target: "https://login.domain.ext.dev01",
secure: false,
changeOrigin: true,
onProxyReq: relayRequestHeaders,
onProxyRes: relayResponseHeaders
}
},
hot: true,
open: true,
progress: true
},
plugins : [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
]
};
developmentConfig = webpackMerge(commonConfig, developmentConfig);
function relayRequestHeaders(proxyReq, req) {}
function relayResponseHeaders(proxyRes, req, res) {
if (proxyRes.headers && proxyRes.headers.location) {
let expression = new RegExp('https://(project\\.(domain\\.ext|alt-domani\\.ext)\\.dev1)/', 'i');
let match = proxyRes.headers.location.match(expression);
if (match) {
proxyRes.headers.location = proxyRes.headers.location.replace(match[1], match[1] + ':8080');
res.append('location', proxyRes.headers.location);
}
}
}